DataGridView控件中的各种事件都无法直接响应Cell中内容的变化,包括KeyPress等事件,可以采用下面方法

无法响应Cell中的回车键

private void dataGridViewBarcode_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)

{

if (e.Control.GetType().Equals(typeof(DataGridViewTextBoxEditingControl)))

{

e.CellStyle.BackColor = Color.FromName("window");

DataGridViewTextBoxEditingControl textControl = e.Control as DataGridViewTextBoxEditingControl;

textControl.TextChanged += new EventHandler(textControl_TextChanged);

}

}

private void textControl_TextChanged(object sender, EventArgs e)

{

this.label1.Text = ((TextBox)sender).Text;

}

相关文章:

  • 2021-11-30
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
猜你喜欢
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案