Confused why my Text box location is always 0 0

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
MessageBox.Show(this.RTB1.Location.X+" "+this.RTB1.Location.Y+"\n"+this.RTB1.Location);

I want to use Cursor.Clip() but I cannot because the location is never right. . .
That text box is not near point 0 0 but it always shows that it is, why?
 
Ok, same problem exept more weird.

Cursor.Position=new Point(saveButton.Location.X, saveButton.Location.Y);

That should put the cursor right on the upper left corner of the button but instead, no matter what object I put it on it is always about 20 pixels above where it needs to be and those are objects that are directly on the form, no panels.

I had the same problem with the paneled objects, I figured out how to get the point of a text box relative to the panles but it is always about 20 pixels above where it needs to be.
 
Use the myButton.PointToScreen(myButton.Location) to get
the location of the button on the screen, rather than relative to the
form.
 
Cursor.Position= this.ExpandedViewB.PointToScreen(this.ExpandedViewB.Location);

If I did that right it is even worse than before. Any idea what is going on? I even tried it on a much less complicated form.
 
If you want to position the cursor on the top-left corner of a button on your form, use this:

C#:
Cursor.Position = Button3.Parent.PointToScreen(Button3.Location);
 
Back
Top