[英]Prevent scrolling to selected row in datagridview when a new row is added
[英]Prevent DataGridView selecting a row when sorted if none was previously selected
我有一个datagridview,当用户通过单击列标题对其进行排序时,可能会或可能不会选择行。 如果选择的行没有问题,但是如果选择的行有0,则排序会自动选择一行(选择是一致的,但我不知道标准是什么)。 如何防止这种行为发生。
如果相关,则DGV没有数据绑定,并且启用了全行选择。
处理DataGridView的Sorted事件:
this.dataGridView1.Sorted += new System.EventHandler(dataGridView1_Sorted);
void dataGridView1_Sorted(object sender, System.EventArgs e)
{
dataGridView1.ClearSelection();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.