【发布时间】:2010-08-24 21:40:26
【问题描述】:
我有一个 C# .NET 3.0 项目,该项目使用包含多行控件的 TableLayoutPanel。如果我向下滚动以使顶部项不再可见,然后删除一列中的控件并将其替换为新控件,则 TableLayoutPanel 将滚动回顶部。
/// the panel in question
private System.Windows.Forms.TableLayoutPanel impl_;
/// The user has clicked a linklabel in the panel. replace it with an edit-box
private void OnClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
LinkLabel link_label = sender as LinkLabel;
TextBox new_edit = new TextBox();
// setup the new textbox...
TableLayoutPanelCellPosition pos = impl_.GetCellPosition(link_label);
impl_.Controls.Remove(link_label);
impl_.Controls.Add(new_edit, pos.Column, pos.Row);
new_edit.Focus();
}
我需要做些什么来防止滚动位置发生变化?
【问题讨论】:
标签: c# user-interface controls scroll tablelayoutpanel