主婦と.NETと犬のぶろぐ

奥様 と プログラム と お犬様 の 楽しい日常

目次

Blog 利用状況

ニュース

書庫

日記カテゴリ

HScrollBar(System.Windows.Forms.HScrollBar)と VScrollBar(System.Windows.Forms.VScrollBar)

ScrollableControl の派生クラスじゃないもの(おもに Panel)をスクロールさせたい時に使うと便利。
ScrollableControl だったら、普通に AutoScroll とかありますからね~。

ちょっと悩んだのはスクロールさせたいもの(Panel)の Dock を Fill にしてたらうまくスクロールしなかった事。
よく考えれば当たり前ですね...。

■参考文献
HScrollBar コントロールおよび VScrollBar コントロール (Windows フォーム)
HScrollBar クラス
ScrollableControl.AutoScroll プロパティ

■実行画像
起動したとこ
HScrollBar VScrollBar
スクロールしたとこ
HScrollBar VScrollBar Scrolling
おまけ
HScrollBar VScrollBar Scrolling

Public Class HScrollBarVScrollBarTest

Private m_scrollPanel As Panel Private m_nakasan As PictureBox
Private Sub HScrollBarVScrollBarTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Controls.Clear() Dim tabCtrl As TabControl = New TabControl() tabCtrl.Dock = DockStyle.Fill Me.Controls.Add(tabCtrl)
tabCtrl.TabPages.Clear()
Dim panelScrollPage As TabPage = New TabPage("ScrollTest") tabCtrl.TabPages.Add(panelScrollPage)
Me.m_scrollPanel = New Panel() Me.m_scrollPanel.Size = New Size(300, 300) 'Me.m_scrollPanel.Dock = DockStyle.Fill ' ← これはだめです。
' VScrollVar と HScrollBar の配置 Dim vScroll As VScrollBar = New VScrollBar() vScroll.Dock = DockStyle.Right vScroll.Minimum = 1 vScroll.Maximum = Me.m_scrollPanel.Height + panelScrollPage.ClientSize.Height Dim hScroll As HScrollBar = New HScrollBar() hScroll.Dock = DockStyle.Bottom hScroll.Minimum = 1 hScroll.Maximum = Me.m_scrollPanel.Width + panelScrollPage.ClientSize.Width
panelScrollPage.Controls.Add(vScroll) panelScrollPage.Controls.Add(hScroll) panelScrollPage.Controls.Add(Me.m_scrollPanel)
'Panel 内にコントロールを詰め込む For hIndex As Integer = 10 To 150 Step 140 For vIndex As Integer = 0 To 9 Dim tBox As TextBox = New TextBox() tBox.Text = hIndex.ToString() & "-" & (vIndex + 1).ToString() tBox.Location = New Point(hIndex, 10 + vIndex * 20) Me.m_scrollPanel.Controls.Add(tBox) Next Next 'スクロールされた時のイベントを登録 AddHandler vScroll.ValueChanged, AddressOf Me.VScrollBar_ValueChanged AddHandler hScroll.ValueChanged, AddressOf Me.HScrollBar_ValueChanged
'おまけ Dim nakaSanTabPage As TabPage = New TabPage("中さん") tabCtrl.TabPages.Add(nakaSanTabPage)
Me.m_nakasan = New PictureBox() Me.m_nakasan.Image = My.Resources.中さん Me.m_nakasan.SizeMode = PictureBoxSizeMode.Zoom Me.m_nakasan.Size = New Size(300, 300) Me.m_nakasan.Location = New Point(0, 0)
' VScrollVar と HScrollBar の配置 Dim nvScroll As VScrollBar = New VScrollBar() nvScroll.Dock = DockStyle.Left nvScroll.Minimum = 1 nvScroll.Maximum = Me.m_nakasan.Height nvScroll.Value = nvScroll.Maximum
Dim nhScroll As HScrollBar = New HScrollBar() nhScroll.Dock = DockStyle.Bottom nhScroll.Minimum = 1 nhScroll.Maximum = Me.m_nakasan.Width nhScroll.Value = nhScroll.Maximum
nakaSanTabPage.Controls.Add(nvScroll) nakaSanTabPage.Controls.Add(nhScroll) nakaSanTabPage.Controls.Add(Me.m_nakasan)
'移動情報の取得 AddHandler nvScroll.Scroll, AddressOf NakasanScrollBar_Scroll AddHandler nhScroll.Scroll, AddressOf NakasanScrollBar_Scroll 'スクロールされた時のイベントを登録 AddHandler nvScroll.ValueChanged, AddressOf NVScrollBar_ValueChanged AddHandler nhScroll.ValueChanged, AddressOf NHScrollBar_ValueChanged
End Sub
Private Sub VScrollBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim vScroll As VScrollBar = DirectCast(sender, VScrollBar) Me.m_scrollPanel.Top = -vScroll.Value End Sub
Private Sub HScrollBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim hScroll As HScrollBar = DirectCast(sender, HScrollBar) Me.m_scrollPanel.Left = -hScroll.Value End Sub
' 中さん関連 Private Sub NVScrollBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Me.m_nakasan.Size = New Size(Me.m_nakasan.Size.Width, DirectCast(sender, VScrollBar).Value) End Sub
Private Sub NHScrollBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Me.m_nakasan.Size = New Size(DirectCast(sender, HScrollBar).Value, Me.m_nakasan.Size.Height) End Sub
Private Sub NakasanScrollBar_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) System.Diagnostics.Debug.WriteLine("移動方向:" & e.ScrollOrientation.ToString()) System.Diagnostics.Debug.WriteLine("移動種類:" & e.Type.ToString()) System.Diagnostics.Debug.WriteLine("前の値:" & e.OldValue.ToString()) System.Diagnostics.Debug.WriteLine("新しい値:" & e.NewValue.ToString()) End Sub End Class

投稿日時 : 2007年1月25日 8:46

Feedback

# I constantly spent my half an hour to read this web site's content daily along with a cup of coffee. 2021/09/03 17:38 I constantly spent my half an hour to read this we

I constantly spent my half an hour to read this web site's content daily along with a cup of coffee.

# I constantly spent my half an hour to read this web site's content daily along with a cup of coffee. 2021/09/03 17:39 I constantly spent my half an hour to read this we

I constantly spent my half an hour to read this web site's content daily along with a cup of coffee.

# I constantly spent my half an hour to read this web site's content daily along with a cup of coffee. 2021/09/03 17:40 I constantly spent my half an hour to read this we

I constantly spent my half an hour to read this web site's content daily along with a cup of coffee.

# Hello, I desire to subscribe for this weblog to take newest updates, thus where can i do it please assist. quest bars http://j.mp/3C2tkMR quest bars 2021/09/10 19:01 Hello, I desire to subscribe for this weblog to ta

Hello, I desire to subscribe for this weblog to take
newest updates, thus where can i do it please assist. quest bars http://j.mp/3C2tkMR quest bars

# Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and screamed. There was a hermit crab inside and 2021/09/14 10:39 Today, I went to the beachfront with my kids. I fo

Today, I went to the beachfront with my kids.

I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and
screamed. There was a hermit crab inside and it pinched her
ear. She never wants to go back! LoL I know this is
entirely off topic but I had to tell someone! quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and screamed. There was a hermit crab inside and 2021/09/14 10:40 Today, I went to the beachfront with my kids. I fo

Today, I went to the beachfront with my kids.

I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and
screamed. There was a hermit crab inside and it pinched her
ear. She never wants to go back! LoL I know this is
entirely off topic but I had to tell someone! quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and screamed. There was a hermit crab inside and 2021/09/14 10:41 Today, I went to the beachfront with my kids. I fo

Today, I went to the beachfront with my kids.

I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and
screamed. There was a hermit crab inside and it pinched her
ear. She never wants to go back! LoL I know this is
entirely off topic but I had to tell someone! quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and screamed. There was a hermit crab inside and 2021/09/14 10:42 Today, I went to the beachfront with my kids. I fo

Today, I went to the beachfront with my kids.

I found a sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to her ear and
screamed. There was a hermit crab inside and it pinched her
ear. She never wants to go back! LoL I know this is
entirely off topic but I had to tell someone! quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# This website was... how do I say it? Relevant!! Finally I've found something which helped me. Appreciate it! scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery 2021/09/14 16:07 This website was... how do I say it? Relevant!! F

This website was... how do I say it? Relevant!! Finally
I've found something which helped me. Appreciate it!
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# This website was... how do I say it? Relevant!! Finally I've found something which helped me. Appreciate it! scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery 2021/09/14 16:08 This website was... how do I say it? Relevant!! F

This website was... how do I say it? Relevant!! Finally
I've found something which helped me. Appreciate it!
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# This website was... how do I say it? Relevant!! Finally I've found something which helped me. Appreciate it! scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery 2021/09/14 16:09 This website was... how do I say it? Relevant!! F

This website was... how do I say it? Relevant!! Finally
I've found something which helped me. Appreciate it!
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# This website was... how do I say it? Relevant!! Finally I've found something which helped me. Appreciate it! scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery 2021/09/14 16:10 This website was... how do I say it? Relevant!! F

This website was... how do I say it? Relevant!! Finally
I've found something which helped me. Appreciate it!
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

# Why people still make use of to read news papers when in this technological world all is presented on web? https://parttimejobshiredin30minutes.wildapricot.org/ part time jobs hired in 30 minutes 2021/10/22 22:51 Why people still make use of to read news papers w

Why people still make use of to read news papers when in this technological world all is presented on web?

https://parttimejobshiredin30minutes.wildapricot.org/ part time jobs hired in 30 minutes

# Hello, after reading this amazing paragraph i am too glad to share my experience here with mates. 2021/10/26 19:59 Hello, after reading this amazing paragraph i am t

Hello, after reading this amazing paragraph i am too glad
to share my experience here with mates.

# Hello, after reading this amazing paragraph i am too glad to share my experience here with mates. 2021/10/26 20:00 Hello, after reading this amazing paragraph i am t

Hello, after reading this amazing paragraph i am too glad
to share my experience here with mates.

# Hello, after reading this amazing paragraph i am too glad to share my experience here with mates. 2021/10/26 20:01 Hello, after reading this amazing paragraph i am t

Hello, after reading this amazing paragraph i am too glad
to share my experience here with mates.

# Hello, after reading this amazing paragraph i am too glad to share my experience here with mates. 2021/10/26 20:02 Hello, after reading this amazing paragraph i am t

Hello, after reading this amazing paragraph i am too glad
to share my experience here with mates.

# Hi there to all, how is the whole thing, I think every one is getting more from this web page, and your views are good designed for new people. 2022/01/12 20:27 Hi there to all, how is the whole thing, I think e

Hi there to all, how is the whole thing, I think every one is getting more from this web page, and your
views are good designed for new people.

# purchase doxycycline online https://doxycyline1st.com/
doxycycline hyc 100mg 2022/02/26 9:57 Jusidkid

purchase doxycycline online https://doxycyline1st.com/
doxycycline hyc 100mg

# clomid prescription https://clomiden.fun/ 2022/04/12 13:13 Clomids

clomid prescription https://clomiden.fun/

# prednisone https://prednisoneus.shop/ 2022/04/16 23:07 Prednisone

prednisone https://prednisoneus.shop/

# ivermectin nobel prize https://stromectolbestprice.com/ 2022/07/30 0:47 BestPrice

ivermectin nobel prize https://stromectolbestprice.com/

# where can i order prednisone 20mg https://deltasone.icu/
5 mg prednisone tablets 2022/08/22 9:57 Prednisone

where can i order prednisone 20mg https://deltasone.icu/
5 mg prednisone tablets

# pills for erection https://ed-pills.xyz/
male erection pills 2022/09/16 7:48 EdPills

pills for erection https://ed-pills.xyz/
male erection pills

# buy doxycycline without prescription uk https://antibiotic.best/ 2022/10/08 3:55 Antibiotic

buy doxycycline without prescription uk https://antibiotic.best/

# doxycycline 500mg https://buydoxycycline.icu/ 2022/10/08 12:04 Doxycycline

doxycycline 500mg https://buydoxycycline.icu/

#  https://clomidforsale.site/ 2022/11/13 14:35 ForSale

https://clomidforsale.site/

# men's ed pills https://edpills.science/
best ed pills 2023/01/07 8:51 Edpills

men's ed pills https://edpills.science/
best ed pills

# Learn about the side effects, dosages, and interactions. Actual trends of drug.
https://edonlinefast.com
Read information now. Cautions. 2023/02/17 11:26 EdOnline

Learn about the side effects, dosages, and interactions. Actual trends of drug.
https://edonlinefast.com
Read information now. Cautions.

# buy doxycycline for dogs - https://doxycyclinesale.pro/# 2023/04/21 17:45 Doxycycline

buy doxycycline for dogs - https://doxycyclinesale.pro/#

# 200 mg prednisone daily - https://prednisonesale.pro/# 2023/04/22 5:03 Prednisone

200 mg prednisone daily - https://prednisonesale.pro/#

# erectile dysfunction pills: https://edpills.pro/# 2023/05/15 15:49 EdPillsPro

erectile dysfunction pills: https://edpills.pro/#

# paxlovid pill https://paxlovid.pro/# - buy paxlovid online 2023/07/02 17:42 Paxlovid

paxlovid pill https://paxlovid.pro/# - buy paxlovid online

# paxlovid india https://paxlovid.store/
paxlovid 2023/07/13 13:32 Paxlovid

paxlovid india https://paxlovid.store/
paxlovid

# paxlovid generic https://paxlovid.life/# paxlovid price 2023/07/25 20:51 Paxlovid

paxlovid generic https://paxlovid.life/# paxlovid price

# 3000mg valtrex https://valtrex.auction/ australia price for valtrex 2023/10/24 22:35 Valtrex

3000mg valtrex https://valtrex.auction/ australia price for valtrex

# paxlovid cost without insurance https://paxlovid.bid/ Paxlovid buy online 2023/10/25 23:25 Paxlovid

paxlovid cost without insurance https://paxlovid.bid/ Paxlovid buy online

# vibramycin 100 mg https://doxycycline.forum/ buy doxycycline cheap 2023/11/25 13:37 Doxycycline

vibramycin 100 mg https://doxycycline.forum/ buy doxycycline cheap

# migliori farmacie online 2023 https://farmaciait.pro/ farmacie online sicure 2023/12/04 10:29 Farmacia

migliori farmacie online 2023 https://farmaciait.pro/ farmacie online sicure

# best over the counter ed pills https://edpills.tech/# ed medications 2023/12/23 8:33 EdPills

best over the counter ed pills https://edpills.tech/# ed medications

タイトル
名前
Url
コメント