Link to home
Start Free TrialLog in
Avatar of hansw77041
hansw77041

asked on

How to position a control on a form at run time

I have a form that can be resized.
I need to position the grid control so that it remains at X,Y relative to the top left of the form.

Point NewPos  = new Point(20,50);
dataGridView1.Location = NewPos;

When I set a breakpoint dataGridView1.Location  show 0,0 and not 20,50

Just what do I need to do to position a control where I want it.
 
Avatar of doraiswamy
doraiswamy
Flag of India image

If you set the breakpoint at dataGridView1.Location = NewPos;
then the statement has not executed as yet. So the location will still be the original vaue
>>I have a form that can be resized.
>>I need to position the grid control so that it remains at X,Y relative to the top left of the form.

Does it moves when you resize the form?
Do you want the grid to be resized with form? If so, you just have to set the grid's Anchor property to left,top,right,bottom
ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hansw77041
hansw77041

ASKER

That did it... thanks