私はdatagridviewセルのキープレスイベントで1つの選択ボックスをポップアップしようとしています。選択ボックスのポップアップは機能していますが、上下のキーが起動しません datagridviewセルから上下のキーを押しながら選択ボックスのデータを上下に移動したい
これらのコードは使用しています
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
DataGridView dttmp = (DataGridView)sender;
csearch = "";
var txtbox = e.Control as TextBox;
if (txtbox != null)
{
txtbox.KeyPress -= new KeyPressEventHandler(textBoxPart_TextChanged);
txtbox.KeyPress += new KeyPressEventHandler(textBoxPart_TextChanged);
txtbox.Validating -= new CancelEventHandler(txtbox_Validating);
txtbox.Validating += new CancelEventHandler(txtbox_Validating);
txtbox.LostFocus += new EventHandler(txtbox_LostFocus);
}
}
private void textBoxPart_TextChanged(object sender, KeyPressEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 1)
{
if (e.KeyChar == Convert.ToChar(Keys.Up))
{
if (srchbox.Rows.Count > 1)
{
int curind = srchbox.CurrentRow.Index;
//srchbox.Rows[curind - 1].Selected = true;
if (curind - 1 >= 0)
{
srchbox.CurrentCell = srchbox.Rows[curind - 1].Cells[1];
srchbox.Refresh();
}
}
e.Handled = true;
}
}