regarding location of controls
-
Dear All, How to make sure that controls on the form do not change their location when Form scroll event occurs ? I am having a form and I drag and drop a textbox in it. I enable the scroll event of the form. Now when ever I scroll up/down the textbox control is changing its location i,e. its co-ordinates X and Y. I am writing the following code snippet in the scroll event, private void Form1_Scroll(object sender, ScrollEventArgs e) { textBox1.Text = textBox1.Location.ToString(); textBox2.Text = textBox2.Location.ToString(); textBox3.Text = textBox3.Location.ToString(); } Please help me in solving this problem. Thanx
-
Dear All, How to make sure that controls on the form do not change their location when Form scroll event occurs ? I am having a form and I drag and drop a textbox in it. I enable the scroll event of the form. Now when ever I scroll up/down the textbox control is changing its location i,e. its co-ordinates X and Y. I am writing the following code snippet in the scroll event, private void Form1_Scroll(object sender, ScrollEventArgs e) { textBox1.Text = textBox1.Location.ToString(); textBox2.Text = textBox2.Location.ToString(); textBox3.Text = textBox3.Location.ToString(); } Please help me in solving this problem. Thanx
Mr Perfect wrote:
textBox1.Text = textBox1.Location.ToString(); textBox2.Text = textBox2.Location.ToString(); textBox3.Text = textBox3.Location.ToString();
Here you are not changing the position of the text box. You are just assigning the location to the text property. If you want that the text box should not move even when the scroll bar is scrolled, try to change the location of the text box in the same event. Please check the ScrollEventArgs for the new value of the scroll bar, using which you can change the location of the text boxes.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
-
Mr Perfect wrote:
textBox1.Text = textBox1.Location.ToString(); textBox2.Text = textBox2.Location.ToString(); textBox3.Text = textBox3.Location.ToString();
Here you are not changing the position of the text box. You are just assigning the location to the text property. If you want that the text box should not move even when the scroll bar is scrolled, try to change the location of the text box in the same event. Please check the ScrollEventArgs for the new value of the scroll bar, using which you can change the location of the text boxes.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
I want the location of the textbox to remain same(fixed), whenever the scroll event occurs.
-
I want the location of the textbox to remain same(fixed), whenever the scroll event occurs.
Hi, I got your point already. You dont want the text boxes to be scrolled out of the screen. correct ? Thats why you will need to change the location of the text boxes according to the new values of the scroll bar. In this way your text boxes will appear as if "Fixed"
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder