是否有 DataGridViewCell
的 Keydown
事件?
我想要做的是,当用户在特定单元格中键入内容时,他可以按 F1 键以获得该特定列的帮助。并且会弹出一些表单...
这是什么事件?
最佳答案
我找到了 this在论坛中编写代码,并且有效。
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
DataGridViewTextBoxEditingControl tb = (DataGridViewTextBoxEditingControl)e.Control;
tb.KeyPress += new KeyPressEventHandler(dataGridViewTextBox_KeyPress);
e.Control.KeyPress += new KeyPressEventHandler(dataGridViewTextBox_KeyPress);
}
private void dataGridViewTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
//when i press enter,bellow code never run?
if (e.KeyChar==(char)Keys.Enter)
{
MessageBox.Show("You press Enter");
}
}
关于c# - 如何处理 DataGridViewCell 中的 KeyEvents?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3697517/