DataGridView默認不選中任何單元格或者行


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;

------解決方案--------------------
探討
dataGridView1.ClearSelection();
或者
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;

------解決方案--------------------
探討
dataGridView1.ClearSelection();
或者
dataGridView1.CurrentCell=null;

------解決方案--------------------
設置datagrid的selectable屬性為false或手工設置選中的行就可以了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM