DataGridView控件中的各种事件都无法直接响应Cell中内容的变化,包括KeyPress等事件采用下面方法
private void dataGridViewBarcode_EditingControlShowing( sender, DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control.GetType().Equals(typeof(DataGridViewTextBoxEditingControl)))
{
e.CellStyle.BackColor = Color.FromName(\"window\");
DataGridViewTextBoxEditingControl editingControl = e.Control as DataGridViewTextBoxEditingControl;
editingControl.TextChanged += new EventHandler(editingControl_TextChanged);
}
}
private void textControl_TextChanged( sender, EventArgs e)
{
this.label1.Text = ((TextBox)sender).Text;
}
注:此方法无法响应Cell中的回车键
继续阅读与本文标签相同的文章
上一篇 :
什么是SQL?
-
Confluence 6.15 修改历史(Change-History)宏
2026-05-19栏目: 教程
-
SpringBoot2 整合 Dubbo框架 ,实现RPC服务远程调用
2026-05-19栏目: 教程
-
企业为什么要“多”申请专利?
2026-05-19栏目: 教程
-
为什么说中小型企业比较适合选择云服务器租用呢?
2026-05-19栏目: 教程
-
等保2.0必须关注的点
2026-05-19栏目: 教程
