2014-09-29 61 views
0

我有一個SQL Server數據庫,其中包含一個bit列,每當一個複選框被點擊我想用當前值更新位列。如何更新dataGridView中的複選框值?

在我的C#程序創建活動時,點擊的dataGridView更新數據

TXT_COURSE_ID.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); 
TXT_COURSE_name.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString(); 
TXT_COURSE_TERM.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); 

// HERE IS THE PROBLEM: 
CHECK_LAB.CheckState = dataGridView1.CurrentRow.Cells[3].Value.ToString(); 

回答

0

的問題是,你需要看看CheckState屬性的類型和你想設置什麼。 CheckState enum與字符串不一樣。

你應該做這樣的事情:

CHECK_LAB.Checked = bool.Parse(dataGridView1.CurrentRow.Cells[3].Value.ToString()); 
+0

THANK YOU SOOOOO MUCH ..成功更改了:) – user3364343 2014-09-29 11:18:07