Reputation: 677
High level question, is it possible to move a control from a method? Example, I have a label
and a button click event
, can the label
move from one position (X,Y)
to another from the button click to something like (X+20,Y+20)
?
I haven't had any luck with changing the .Position
property of the label, and I couldn't find anything online so I thought I would ask. Thanks!
EDIT: Was asked to show some code so here ya go. The label1.Position can't be selected/edited, and label1.Move is an event handler, for when the user moves the label?
private void MoveTextButton_Click(object sender, EventArgs e)
{
label1.Position = (x,y);
//label1.Move
}
Upvotes: 1
Views: 1093
Reputation: 2980
Just change Location
like :
private void MoveTextButton_Click(object sender, EventArgs e)
{
label1.Location = new Point(label1.Location.X + 20, label1.Location.Y + 20);
}
Upvotes: 2