SnA*_*BaZ 60 c# textbox winforms
我在C#Forms应用程序上有一个TextBox.我使用有关窗体的Load事件的信息填充TextBox.然后我打电话给以下人员:
this.txtLogEntries.SelectionStart = txtLogEntries.Text.Length;
this.txtLogEntries.ScrollToCaret();
Run Code Online (Sandbox Code Playgroud)
但是TextBox不会滚动到底部?
这仅适用于Load事件.我还会在应用程序运行时从应用程序的其他部分更新此TextBox,并且只要其中一个事件更新为TextBox,它就会滚动到底部.
那么,如何在Form Load事件中预先填充TextBox时将其滚动到底部?
ber*_*hof 92
尝试将代码放在Form的Shown事件中:
private void myForm_Shown(object sender, EventArgs e)
{
txtLogEntries.SelectionStart = txtLogEntries.Text.Length;
txtLogEntries.ScrollToCaret();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31868 次 |
| 最近记录: |