Scroll bar Problem

  • Thread starter Thread starter Whiz
  • Start date Start date
W

Whiz

I have a Panel and a vertical scroll bar on my windows form.How can I
resize of the form (and scrollbar) when the SIP is visible ?

I am writing this in VB.Net. Can some one tell me how to do that.

Thanks
Whiz
 
Handle the Input Panel's EnabledChanged event, and resize the scroll
bar based on the InputPanel's VisibleDesktop.
 
Thanks Marston.I wrote the following code to resize of the form, but
that's not working. Can you tell me where am I going wrong in the code.


Private Sub InputPanel_EnabledChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles InputPanel.EnabledChanged


Me.Panel1.Top = -Me.VScrollBar1.Value

Const NO_OF_PAGES = 1

' Define the size of the scrollbar
If (InputPanel1.Enabled = True) Then
' Set size of scrollbar
VScrollBar1.Height = SB_HEIGHT_SIP
VScrollBar1.Maximum = Panel1.Height - SB_HEIGHT_SIP

Else
VScrollBar1.Height = SB_HEIGHT_NOSIP
VScrollBar1.Maximum = Panel1.Height - SB_HEIGHT_NOSIP

VScrollBar1.LargeChange = (VScrollBar1.Maximum /
(NO_OF_PAGES - 1)) + 1
VScrollBar1.Maximum = VScrollBar1.LargeChange * NO_OF_PAGES
- NO_OF_PAGES
Panel1.Top = -VScrollBar1.Value
End If

VScrollBar1.Minimum = 0

VScrollBar1.SmallChange = VScrollBar1.Maximum / 100
VScrollBar1.LargeChange = VScrollBar1.Maximum / 10

Call setupScrollBar()
End Sub

Whiz
 
Thanks Marston.I wrote the following code to resize of the form, but
that's not working. Can you tell me where am I going wrong in the code.


Private Sub InputPanel_EnabledChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles InputPanel.EnabledChanged


Me.Panel1.Top = -Me.VScrollBar1.Value

Const NO_OF_PAGES = 1

' Define the size of the scrollbar
If (InputPanel1.Enabled = True) Then
' Set size of scrollbar
VScrollBar1.Height = SB_HEIGHT_SIP
VScrollBar1.Maximum = Panel1.Height - SB_HEIGHT_SIP

Else
VScrollBar1.Height = SB_HEIGHT_NOSIP
VScrollBar1.Maximum = Panel1.Height - SB_HEIGHT_NOSIP

VScrollBar1.LargeChange = (VScrollBar1.Maximum /
(NO_OF_PAGES - 1)) + 1
VScrollBar1.Maximum = VScrollBar1.LargeChange * NO_OF_PAGES
- NO_OF_PAGES
Panel1.Top = -VScrollBar1.Value
End If

VScrollBar1.Minimum = 0

VScrollBar1.SmallChange = VScrollBar1.Maximum / 100
VScrollBar1.LargeChange = VScrollBar1.Maximum / 10

End Sub

Whiz
 
The below code I found in that sample is in C#.And I am new to C#.In
the below c# sample it's declared as

const int NO_OF_PAGES = 2;

and I worte that in VB as

Const NO_OF_PAGES = 1

How can I write these piece of code in VB.Net

vScrollBar1.LargeChange = (int)(vScrollBar1.Maximum / (NO_OF_PAGES -
1)) + 1;

I am not able to figure out how to write this in VB.Net. Can you help
me how to do that in VB.net.

private void pResizeScrollBar()
{
const int NO_OF_PAGES = 2;

if (inputPanel1.Enabled)
{
vScrollBar1.Height = SB_HEIGHT_SIP;
vScrollBar1.Maximum = panel1.Height - SB_HEIGHT_SIP;
}
else
{
vScrollBar1.Height = SB_HEIGHT_NOSIP;
vScrollBar1.Maximum = panel1.Height - SB_HEIGHT_NOSIP;
}
vScrollBar1.LargeChange = (int)(vScrollBar1.Maximum /
(NO_OF_PAGES - 1)) + 1;
vScrollBar1.Maximum = vScrollBar1.LargeChange * NO_OF_PAGES -
NO_OF_PAGES;

panel1.Top = -vScrollBar1.Value;
}

Thanks
Whiz
 
Back
Top