1

私は DataGridViewComboBoxColumn を持っていますDropDownStyle = ComboBoxStyle.Simple

キーストロークでドロップダウンを強制的に展開するにはどうすればよいですか?

((ComboBox)?).DroppedDown = true;解決せずにいくつかの場所に入れてみました

4

1 に答える 1

0

次のコード スニペットが機能するはずです。

//If no row/cell selected, select an appropriate row/cell
dataGridView1.Rows[0].Selected = true;
dataGridView1.Rows[0].Cells[0].Selected = true;

//Start edit mode or otherwise EditingControl property will return null
dataGridView1.BeginEdit(true);

var comboBox = dataGridView1.EditingControl as DataGridViewComboBoxEditingControl;

if (comboBox != null)
{
   comboBox.DroppedDown = true;
}

これが機能するためには、バインディングを介して入力するか手動で入力するかのいずれかで、コンボボックスに項目が存在する必要があることに注意してください。

于 2012-07-22T22:26:49.953 に答える