0

次のDataGridViewように定義された2つの列があります。

Dim col As New DataGridViewColumn
col.DefaultCellStyle.BackColor = Color.FromArgb(&HFFAAAAAA)
col.Name = "Description"
col.MinimumWidth = 80
col.DataPropertyName = "Description"
col.ValueType = GetType(String)
col.ReadOnly = True
col.CellTemplate = New DataGridViewTextBoxCell
S0Grid.Columns.Add(col)

col = New DataGridViewColumn
col.DefaultCellStyle.BackColor = Color.FromArgb(&HFFBBBBBB)
col.Name = "Value"
col.MinimumWidth = 80
col.DataPropertyName = "Value"
col.ValueType = GetType(String)
col.CellTemplate = New DataGridViewTextBoxCell
S0Grid.Columns.Add(col)

位置 Col=1, Row=0 のセルが aComboBoxではなく a である必要がありTextBoxます。そのため、次のコードを追加しようとしましたが、機能しません。編集コントロールは TextBox のままです。

Dim cbCell As New
DataGridViewComboBoxCell
cbCell.Items.AddRange([Enum].GetNames(GetType(System.Reflection.BindingFlags)))
S0Grid(1, 0) = cbCell

どうすればこの問題を解決できるか知っていますか?

4

1 に答える 1

0

そのコードは機能するはずですが、呼び出されていないか、スローされている可能性はありますか?

このコードを試してください:

Dim cbCell As New DataGridViewComboBoxCell
S0Grid(1, 0) = cbCell
MessageBox.Show("Test")

メッセージボックスが見えますか?そして、あなたは今コンボを見ますか?

于 2010-06-21T13:35:07.163 に答える