I have a C# .NET 3.0 project that uses a TableLayoutPanel containing several rows of controls. If I scroll down such that the top item is no longer visible, then remove a control in one column and replace it with a new control, the TableLayoutPanel scrolls back to the top.
/// 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();
}
What do I need to do to keep the scroll position from changing?