Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get the location of a particular control using C#/.NET for a Windows Forms application.

Please help me with this.

[edit]OP added as a comment:

i want to generate a dynamic label multiple inside a panel and i have more than 1 forms so how to handle it all dynamically - amitthakkar1987

OriginalGriff[/edit]
Posted
Updated 21-Aug-10 4:24am
v3

The Control.Location property does it for me...
 
Share this answer
 
Comments
Nish Nishant 21-Aug-10 9:48am    
Reason for my vote of 5
Proposed answer.
amitthakkar1987 21-Aug-10 10:20am    
i want to generate a dynamic label multiple inside a panel and i have more than 1 forms so how to handle it all dynamically
If the panel is part of the form, then use the panel name (lets call it MyPanel)
Then, add your label controls to the panel - we will assume the label strings are in an array or list called myLabelStrings:
int x = 10;
int y = 10;
foreach (string s in myLabelStrings)
   {
   Label l = new Label();
   l.Text = s;
   l.Location.X = x;
   l.Location.Y = y;
   l.Visible = true;
   y += 50;
   MyPanel.Controls.Add(l);
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900