How to change the place of textbox when changing the size of the form

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) ;
}

将文本框固定到表单的底部和右侧,如下所示:

// Anchor the text box to the bottom right corner of the form
infoTxt.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);

最好的办法是使用锚点和码头文本框

链接地址: http://www.djcxy.com/p/58374.html

上一篇: UserControl的属性不会更新y

下一篇: 如何在更改表单大小时更改文本框的位置