麻烦看一下,为什么不执行回车事件??
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = ds.Tables[0].TableName;
DataGridTextBoxColumn tbc1 = new DataGridTextBoxColumn();
tbc1.MappingName = "营业员编号";
tbc1.HeaderText = "1";
tbc1.TextBox.KeyDown += new KeyEventHandler(this.Column_KeyDown);
ts.GridColumnStyles.Add(tbc1);
DataGridTextBoxColumn tbc2 = new DataGridTextBoxColumn();
tbc2.MappingName = "营业员姓名";
tbc2.HeaderText = "2";
tbc2.TextBox.KeyDown += new KeyEventHandler(this.Column_KeyDown);
ts.GridColumnStyles.Add(tbc2);
dataGrid1.TableStyles.Add(ts);
dataGrid1.DataSource = ds.Tables[0].DefaultView;
-----------------------------------------
private void Column_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
this.SalesPeople = dataGrid1[dataGrid1.CurrentCell.RowNumber,0].ToString();
this.DialogResult = DialogResult.OK;
}
}