Reputation: 558
I have a textbox which gives the info of the creator/updater and the dates of creation/update of the data in the database when a data is clicked on listbox. The textbox is placed at the right side bottom of the form.
When user modify the size by dragging the form it changes the location of the info textbox
Is it possible to move the textbox with SizeChanged event and how?(By passing the textchanged)
I've tried but I could not do it. I assigned TextChanged to SizeChanged event. It works!
But there must be a way to do it WITHOUT USING the TextChanged event.
Here is my code which works but it unsatisfies me.
private void infoTxt_TextChanged (object sender, EventArgs e)
{
infoTxt.Top = (this.Height - this.Top) + infoTxt.Height* 3/4 ;
infoTxt.Left = this.Width - (infoTxt.Width) ;
}
Upvotes: 2
Views: 150
Reputation: 34844
Anchor the textbox to the bottom and right of the form, like this:
// Anchor the text box to the bottom right corner of the form
infoTxt.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
Upvotes: 4