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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UmljaA==?=

    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 mnuExtendScroll Bar_Click(...) Handles mnuExtendScroll Bar.Click
    Console.WriteLi ne("Before: " & btnAnchor.Locat ion.X.ToString)
    If mnuExtendScroll Bar.Text.Equals ("Extend Bottom Scrollbar") Then
    Me.btnAnchor.Lo cation = New System.Drawing. Point(1050, 3)
    mnuExtendScroll Bar.Text = "De-extend Bottom Scrollbar"
    Else
    '--this is the original/default location of my anchor button
    Me.btnAnchor.Lo cation = New System.Drawing. Point(858, 3)
    mnuExtendScroll Bar.Text = "Extend Bottom Scrollbar"
    End If
    Console.WriteLi ne("After: " & btnAnchor.Locat ion.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
  • =?Utf-8?B?UmljaA==?=

    #2
    RE: prob setting location of button on form and resetting loc to orig

    I change my code slightly - changed Else to ElseIF:

    Private Sub mnuExtendScroll Bar_Click(...) Handles mnuExtendScroll Bar.Click
    Console.WriteLi ne("Before: " & btnAnchor.Locat ion.X.ToString)
    If mnuExtendScroll Bar.Text.Equals ("Extend Bottom Scrollbar") Then
    Me.btnAnchor.Lo cation = New System.Drawing. Point(1050, 3)
    mnuExtendScroll Bar.Text = "De-extend Bottom Scrollbar"
    ElseIf mnuExtendScroll Bar.Text.Equals ("De-extend Bottom Scrollbar") Then
    '--this is the original/default location of my anchor button
    Me.btnAnchor.Lo cation = New System.Drawing. Point(858, 3)
    mnuExtendScroll Bar.Text = "Extend Bottom Scrollbar"
    End If
    Console.WriteLi ne("After: " & btnAnchor.Locat ion.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 mnuExtendScroll Bar_Click(...) Handles mnuExtendScroll Bar.Click
    Console.WriteLi ne("Before: " & btnAnchor.Locat ion.X.ToString)
    If mnuExtendScroll Bar.Text.Equals ("Extend Bottom Scrollbar") Then
    Me.btnAnchor.Lo cation = New System.Drawing. Point(1050, 3)
    mnuExtendScroll Bar.Text = "De-extend Bottom Scrollbar"
    Else
    '--this is the original/default location of my anchor button
    Me.btnAnchor.Lo cation = New System.Drawing. Point(858, 3)
    mnuExtendScroll Bar.Text = "Extend Bottom Scrollbar"
    End If
    Console.WriteLi ne("After: " & btnAnchor.Locat ion.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

    Comment

    Working...