Hi
Is it possible to resize, repositioning controls like (TextBox, Label, ....) during runtime on window Forms in (DotNet). How to proceed with this.
Thanks
Sriram
|
| S.Sriram Thursday, May 11, 2006 8:57 AM |
private void textBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
//Get current X and Y
int x = e.X;
int y =e.Y;
//get deltax and deltay
textBox1.Left += (x-deltaX);
textBox1.Top += (y-deltaY);
}
}
private void textBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
deltaX = e.X;
deltaY = e.Y;
} |
| Karthik Krishnaswami Thursday, May 11, 2006 10:42 AM |
Do you want to do it something like the VS.net designer?
If not,you can set the Location property and Size property at any point of time.
|
| Karthik Krishnaswami Thursday, May 11, 2006 9:44 AM |
i will give a scenario, while at run time is it possible to drag a control (TextBox, label...) to another position, and also resize them. |
| S.Sriram Thursday, May 11, 2006 10:06 AM |
private void textBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
//Get current X and Y
int x = e.X;
int y =e.Y;
//get deltax and deltay
textBox1.Left += (x-deltaX);
textBox1.Top += (y-deltaY);
}
}
private void textBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
deltaX = e.X;
deltaY = e.Y;
} |
| Karthik Krishnaswami Thursday, May 11, 2006 10:42 AM |
Thankyou.. Now iam able to move the textbox to another location at runtime, but is it possible to resize it during runtime
thanks in advance |
| S.Sriram Thursday, May 11, 2006 11:09 AM |
You can-
private void textBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
//Get current X and Y
int x = e.X;
int y =e.Y;
//get deltax and deltay
textBox1.Left += (x-deltaX);
textBox1.Top += (y-deltaY);
textBox1.Height += y-deltaY;
textBox1.Width += x-deltaX;
}
}
This is some skeleton code,which I hope will get you going!!
|
| Karthik Krishnaswami Thursday, May 11, 2006 11:38 AM |
sorry for delayed reply. Actually resize i was looking is different. i mean it should be like how it behaves in design time. (ie) in design time u will select a textbox and on the rightbottom u will select and resize it, the same behaviour is expected in the runtime also for controls. |
| S.Sriram Monday, May 15, 2006 5:38 AM |
|
| Karthik Krishnaswami Monday, May 15, 2006 9:30 AM |