首页 > Windows开发 > 详细

DataGridView中单元格Cell改变事件

时间:2019-03-01 22:41:16      阅读:210      评论:0      收藏:0      [点我收藏+]

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;

}

DataGridView中单元格Cell改变事件

原文:https://www.cnblogs.com/HarryChis/p/10459031.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!