Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. regarding location of controls

regarding location of controls

Scheduled Pinned Locked Moved C#
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Perfect
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • M Mr Perfect

      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

      C Offline
      C Offline
      coolestCoder
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • C 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

        M Offline
        M Offline
        Mr Perfect
        wrote on last edited by
        #3

        I want the location of the textbox to remain same(fixed), whenever the scroll event occurs.

        C 1 Reply Last reply
        0
        • M Mr Perfect

          I want the location of the textbox to remain same(fixed), whenever the scroll event occurs.

          C Offline
          C Offline
          coolestCoder
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups