private void grd1_CurrentCellChanged(object sender, System.EventArgs e)
{
if (this.grd1.CurrentRowIndex < 0)
return;
System.Windows.Forms.DataGridCell cell = this.grd1.CurrentCell;
// Gets the DataGridTextBoxColumn from the DataGrid control.
DataGridTextBoxColumn oTextBoxColumn;
// Assumes the CompanyName column is a DataGridTextBoxColumn.
oTextBoxColumn = (DataGridTextBoxColumn)this.grd1.TableStyles[0].GridColumnStyles[cell.ColumnNumber];
// Gets the DataGridTextBox for the column.
DataGridTextBox oGridTextBox;
oGridTextBox = (DataGridTextBox) oTextBoxColumn.TextBox;
oGridTextBox.KeyDown+= new System.KeyEventHandler(this.YouTextKeyDownEvent);
}
{
if (this.grd1.CurrentRowIndex < 0)
return;
System.Windows.Forms.DataGridCell cell = this.grd1.CurrentCell;
// Gets the DataGridTextBoxColumn from the DataGrid control.
DataGridTextBoxColumn oTextBoxColumn;
// Assumes the CompanyName column is a DataGridTextBoxColumn.
oTextBoxColumn = (DataGridTextBoxColumn)this.grd1.TableStyles[0].GridColumnStyles[cell.ColumnNumber];
// Gets the DataGridTextBox for the column.
DataGridTextBox oGridTextBox;
oGridTextBox = (DataGridTextBox) oTextBoxColumn.TextBox;
oGridTextBox.KeyDown+= new System.KeyEventHandler(this.YouTextKeyDownEvent);
}
解决方案 »
- C# 整理文档问题 求指导(初学者)谢谢
- 一个函数的摘要注释和函数体左侧都有一个节点,用什么快捷方式只展开所有函数的摘要注释节点,而不展开函数代码节点
- 运行时间不定的过程怎样显示进度?
- 做过自动登录的进~~~~整了一天都没整出来。。。
- freetextbox里如何浏览图库的文件夹?
- C#WinForm如何在点击按钮获取数据后,将数据在按钮所在窗体上显示出来
- 一个关于流程实现的问题
- 请问如何在窗体的标题栏上添加自己的按钮,谢谢
- 路由器模拟登陆,返回不了html,这是为什么,求大神指点
- 想求C#的代码编写规范
- c#.net 中如何把一个时间格式化成自己需要的时间格式?
- 我要学C#,大家推荐经典书吧
oGridTextBox.KeyDown+= new System.KeyEventHandler(this.YouTextKeyDownEvent);
中,回车键中不会触发该事件的!(其它键都会触发)
Why!
你可以尝试重新封装一次这个Grid,在外面接受事件,然后进行处理。看看行不行
超出索引范圍﹕
oTextBoxColumn = (DataGridTextBoxColumn)this.dataGrid1.TableStyles[0].GridColumnStyles[cell.ColumnNumber];