469,625 Members | 1,094 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

prob setting location of button on form and resetting loc to orig

I placed a button on a form menustrip for the purpose of causing the
horizontal scrollbar of my form to appear so that I can access controls
outside of the form's current view (the controls are further to the right of
the form than the form's default width - which may take up the entire screen
for some users). The form contains panels which will contain either
textboxes or datagridviews. The button is located on the menustrip towards
the right side of the form - at the edge of the form's default view. If I
then move this button further to the right on the menustrip - it causes the
form's horizontal scrollbar to appear. This way a user can drag the
scrollbar to view the other controls which are located further to the right
of the form. Call this button the 'anchor' button.

In the default form view - the datagridviews (I guess actually the panels
containing the datagridviews) will display their vertical scrollbars (when
there are enough records to require the vertical scrollbars). So I
positioned the anchor button to be in view of the default form's view so that
the datagridviews can have their scrollbars. When I move the anchor button
to the right (through a menu click) the vertical scrollbars of the
datagridviews go out of site - until the user scrolls to the right (some of
the users have their resolution set to 640x480 - bad eyesight). Thus, I
need to be able to reposition this anchor button to its original location to
that the datagridview vertical scrollbars remain in view. The problem is
that when I try to reposition the anchor button to its original location - it
doesn't always go back. If I reposition the button in the beginning -
without scrolling the form horizontally - and the re-reposition the button -
it will go back to its original location. But if I scroll the form and then
try to reposition the button - it won't go back to its original position -
kinda like the new/current position becomes the original position. Here is
the code I am using to perform the positioning/repositioning.

Private Sub mnuExtendScrollBar_Click(...) Handles mnuExtendScrollBar.Click
Console.WriteLine("Before: " & btnAnchor.Location.X.ToString)
If mnuExtendScrollBar.Text.Equals("Extend Bottom Scrollbar") Then
Me.btnAnchor.Location = New System.Drawing.Point(1050, 3)
mnuExtendScrollBar.Text = "De-extend Bottom Scrollbar"
Else
'--this is the original/default location of my anchor button
Me.btnAnchor.Location = New System.Drawing.Point(858, 3)
mnuExtendScrollBar.Text = "Extend Bottom Scrollbar"
End If
Console.WriteLine("After: " & btnAnchor.Location.X.ToString)
End Sub

How can I make the location values not change? make it so the button will
only move to these two locations?

Thanks,
Rich
Oct 6 '08 #1
1 2667
I change my code slightly - changed Else to ElseIF:

Private Sub mnuExtendScrollBar_Click(...) Handles mnuExtendScrollBar.Click
Console.WriteLine("Before: " & btnAnchor.Location.X.ToString)
If mnuExtendScrollBar.Text.Equals("Extend Bottom Scrollbar") Then
Me.btnAnchor.Location = New System.Drawing.Point(1050, 3)
mnuExtendScrollBar.Text = "De-extend Bottom Scrollbar"
ElseIf mnuExtendScrollBar.Text.Equals("De-extend Bottom Scrollbar") Then
'--this is the original/default location of my anchor button
Me.btnAnchor.Location = New System.Drawing.Point(858, 3)
mnuExtendScrollBar.Text = "Extend Bottom Scrollbar"
End If
Console.WriteLine("After: " & btnAnchor.Location.X.ToString)
End Sub

I observed that if I scroll the form back to its original position and then
try to reposition the button - it will go back to its original position (may
take a few clicks though). I would like that button to go back as soon as I
click the menuItem without having to scroll the form back to its original
position.
"Rich" wrote:
I placed a button on a form menustrip for the purpose of causing the
horizontal scrollbar of my form to appear so that I can access controls
outside of the form's current view (the controls are further to the right of
the form than the form's default width - which may take up the entire screen
for some users). The form contains panels which will contain either
textboxes or datagridviews. The button is located on the menustrip towards
the right side of the form - at the edge of the form's default view. If I
then move this button further to the right on the menustrip - it causes the
form's horizontal scrollbar to appear. This way a user can drag the
scrollbar to view the other controls which are located further to the right
of the form. Call this button the 'anchor' button.

In the default form view - the datagridviews (I guess actually the panels
containing the datagridviews) will display their vertical scrollbars (when
there are enough records to require the vertical scrollbars). So I
positioned the anchor button to be in view of the default form's view so that
the datagridviews can have their scrollbars. When I move the anchor button
to the right (through a menu click) the vertical scrollbars of the
datagridviews go out of site - until the user scrolls to the right (some of
the users have their resolution set to 640x480 - bad eyesight). Thus, I
need to be able to reposition this anchor button to its original location to
that the datagridview vertical scrollbars remain in view. The problem is
that when I try to reposition the anchor button to its original location - it
doesn't always go back. If I reposition the button in the beginning -
without scrolling the form horizontally - and the re-reposition the button -
it will go back to its original location. But if I scroll the form and then
try to reposition the button - it won't go back to its original position -
kinda like the new/current position becomes the original position. Here is
the code I am using to perform the positioning/repositioning.

Private Sub mnuExtendScrollBar_Click(...) Handles mnuExtendScrollBar.Click
Console.WriteLine("Before: " & btnAnchor.Location.X.ToString)
If mnuExtendScrollBar.Text.Equals("Extend Bottom Scrollbar") Then
Me.btnAnchor.Location = New System.Drawing.Point(1050, 3)
mnuExtendScrollBar.Text = "De-extend Bottom Scrollbar"
Else
'--this is the original/default location of my anchor button
Me.btnAnchor.Location = New System.Drawing.Point(858, 3)
mnuExtendScrollBar.Text = "Extend Bottom Scrollbar"
End If
Console.WriteLine("After: " & btnAnchor.Location.X.ToString)
End Sub

How can I make the location values not change? make it so the button will
only move to these two locations?

Thanks,
Rich
Oct 6 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Ken | last post: by
reply views Thread by Stuart Norris | last post: by
4 posts views Thread by Ian Davies | last post: by
5 posts views Thread by Finn Stampe Mikkelsen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.