我想只允許編輯DataGridView中的一列,但我想讓用戶雙擊該行中的任何項目,當CellBeginEdit觸發時,強制編輯我的科拉姆。我開始這樣做:在DataGridView上強制編輯爲一列
Private Sub dgvCaptions_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles dgvCaptions.CellBeginEdit
If e.ColumnIndex <> COL_CAPTION Then
e.Cancel = True
dgvCaptions.ClearSelection()
dgvCaptions.Rows(e.RowIndex).Cells(COL_CAPTION).Selected = True
dgvCaptions.BeginEdit(False)
End If
End Sub
但因爲這會引發錯誤的BeginEdit(假)線「操作是無效的,因爲它會導致重入調用BeginEdit功能。」這當然會做,但這是我想要的。有沒有另一種方法來做到這一點?
我不只是想雙擊編輯,我希望用戶按下F2或雙擊該行中的任何項目,這將允許他們只編輯該行中的一列 – 2010-12-17 11:32:54