データセットから入力されたdatagridviewがあります。
入力された後、ユーザーが行をクリックすると、最後の列がテキストボックスからコンボボックスに変わります。
vb.net 2010を使用し
ています。Datagridview1CellClickイベントで:
With DataGridView1
If .Rows.Count = 0 Then Exit Sub
i = Datagridview1.currentrow.index
Dim gridComboBox As New DataGridViewComboBoxCell
gridComboBox.Items.Add("A") 'Populate the Combobox
gridComboBox.Items.Add("B") 'Populate the Combobox
gridComboBox.Items.Add("C") 'Populate the Combobox
.Item(8, i) = gridComboBox
End With
ただし、これによりエラーが発生します。
The following exception occurred in DataGridView:
System.Argument.Exception: DataGridViewComboBoxCell value is not valid.
To replace this default dialog please handle the DataError event.
状況が現実的でない場合は、データセットからデータを入力するときに、最後の列をコンボボックス型にする必要があります。
DataGridView1.DataSource = myDataSet
前もって感謝します。