日期:2014-05-18 浏览次数:20911 次
TextBox tb; private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control.GetType().Name == "DataGridViewTextBoxEditingControl") tb = (TextBox)e.Control; } private void button2_Click(object sender, EventArgs e) { if (tb != null) { int index = tb.SelectionStart; dataGridView1.CurrentCell.Value = tb.Text.Insert(index, this.button2.Text); tb = null; } }