實(shí)現(xiàn)DataGridView控件中CheckBox列的使用實(shí)例
更新時(shí)間:2014年01月20日 14:52:51 作者:
最近做WindowsForms程序,使用DataGridView控件時(shí),加了一列做選擇用,發(fā)現(xiàn)CheckBox不能選中。搜索后,要實(shí)現(xiàn)DataGridView的CellContentClick事件,將代碼貼一下
復(fù)制代碼 代碼如下:
/// <summary>
/// 實(shí)現(xiàn)DataGridView控件中CheckBox列的使用
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgvTradList_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0 && e.RowIndex != -1)
{
if ((bool)dgvTradList.Rows[e.RowIndex].Cells[0].EditedFormattedValue == true)
{
dgvTradList.Rows[e.RowIndex].Cells[0].Value = false;
}
else
{
dgvTradList.Rows[e.RowIndex].Cells[0].Value = true;
}
}
相關(guān)文章
Asp.Net 數(shù)據(jù)操作類(附通用數(shù)據(jù)基類)
數(shù)據(jù)操作類代碼,方便在asp.net操作數(shù)據(jù)庫2008-11-11
ASP.NET:一段比較經(jīng)典的多線程學(xué)習(xí)代碼
ASP.NET:一段比較經(jīng)典的多線程學(xué)習(xí)代碼...2006-09-09
關(guān)于WPF使用MultiConverter控制Button狀態(tài)的詳細(xì)介紹
本篇文章小編將為大家介紹,關(guān)于WPF使用MultiConverter控制Button狀態(tài)的詳細(xì)介紹。需要的朋友參考下2013-04-04
基于自定義Unity生存期模型PerCallContextLifeTimeManager的問題
本篇文章小編將為大家介紹,基于自定義Unity生存期模型PerCallContextLifeTimeManager的問題。需要的朋友參考下2013-04-04

