2011-11-08 66 views
0

在設計器中,我放置了一個DataGridView並添加了幾列。我將DataGridView的「ReadOnly」屬性設置爲false,並將所有列的「ReadOnly」設置爲true,除了名爲「Details」的一個。c#DataGridView:在運行時編輯行單元格

在運行時,我有一個事件處理程序使用dataGridViewInstance.Rows.Add(row);添加一行,其中row是一個字符串數組。

添加後,我希望能夠選擇「詳細信息」列下的單元格,並做筆記,但它不會接受我的輸入。

任何想法我可以做到這一點?

謝謝!

回答

0

你可以像這樣....

嘗試用這樣的形式的任何複選框狀態比較...

private void CheckBox1_CheckedChanged(System.Object sender, System.EventArgs e) 
{ 

    DataGridViewColumn dgvColumn = this.DataGridView1.Columns("Details"); 

    if (this.CheckBox1.CheckState == CheckState.Checked) 
    { 
     dgvColumn.ReadOnly = true; 
    } 
    else 
    dgvColumn.ReadOnly = false;    

} 

我希望它會幫助你...

相關問題