473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2871
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) {...
21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: ...
0
by: Stuart Norris | last post by:
Dear Group, I am having a problem setting SocketOptionName.SendTimeout on a client TCPIP application using the sockets in .NET. From the on-line help it is possible to set a...
7
by: charliewest | last post by:
Using .Net CF, i have created a 2 dimension ArrayList, and "binded" this list to a ComboBox control using the "DataSource" property. I have set the DisplaySource and ValueMember properties as well....
1
by: simon | last post by:
I have an unbound RTF2 control in an Access 2003 form which I set to show either unformatted text or else text with words and sentences highlighted. I do this by setting the PlainText property,...
4
by: Ian Davies | last post by:
Hello I am struggling for a solution to clear some fields on my webpage that takes their values from some sessions My solution below works when the button is clicked twice. I sort of know why I...
5
by: Finn Stampe Mikkelsen | last post by:
Hi How can i set a focus to a textbox in my codebehind page?? I have this WebForm, that takes information from a user and 2 buttons on the form. One that takes action on the entered...
8
by: Andrus | last post by:
..NET 2 Winforms application. How to create new setting and set it default value in userSettings section of app.config file or overwrite existing setting value ? I found code below in this list...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.