DataGridView如何才能默認不選中任何單元格呢?
DataGridView總是會默認選中一行或一個單元格,怎么才能讓它默認不選中呢?
------解決方案--------------------
if (ds.Tables[0].Rows.Count > 0)
{
dataGridView1.Rows[0].Selected = false;/////////////////////////////默認不選擇第一行,既默認不選擇任何行,除非用戶鼠標點擊,使dataGridView2獲得鼠標焦點
}
------解決方案--------------------
dataGridView1.Rows[0].Selected = false;
------解決方案--------------------
if (ds.Tables[0].Rows.Count > 0)
{
dataGridView1.Rows[0].Selected = false
}
如里頁面有其它的控件,讓那個控件得到焦點,也行。
richtext1.Focus;
------解決方案--------------------
-
C# code
dataGridView1.Rows[0].Selected = false;
------解決方案--------------------
dataGridView1.ClearSelection();
或者
dataGridView1.CurrentCell=null;
------解決方案--------------------
-
C# code
dataGridView1.ClearSelection(); OR dataGridView1.CurrentCell=null;
------解決方案--------------------
------解決方案--------------------
設置datagrid的selectable屬性為false或手工設置選中的行就可以了。
DataGridView如何才能默認不選中任何單元格呢?
DataGridView總是會默認選中一行或一個單元格,怎么才能讓它默認不選中呢?
------解決方案--------------------
if (ds.Tables[0].Rows.Count > 0)
{
dataGridView1.Rows[0].Selected = false;/////////////////////////////默認不選擇第一行,既默認不選擇任何行,除非用戶鼠標點擊,使dataGridView2獲得鼠標焦點
}
------解決方案--------------------
dataGridView1.Rows[0].Selected = false;
------解決方案--------------------
if (ds.Tables[0].Rows.Count > 0)
{
dataGridView1.Rows[0].Selected = false
}
如里頁面有其它的控件,讓那個控件得到焦點,也行。
richtext1.Focus;
------解決方案--------------------
-
C# code
dataGridView1.Rows[0].Selected = false;
------解決方案--------------------
dataGridView1.ClearSelection();
或者
dataGridView1.CurrentCell=null;
------解決方案--------------------
-
C# code
dataGridView1.ClearSelection(); OR dataGridView1.CurrentCell=null;
------解決方案--------------------
------解決方案--------------------
設置datagrid的selectable屬性為false或手工設置選中的行就可以了。