我正在制作一个窗体应用程序,其中我使用了一个datagridview。 我想,当我写在文本中datagridview的东西,不是一个消息框出现包含我写的字符串.. ican't让我在TextChanged事件文本..如何从datagridview textchanged事件中的当前单元格中获取文本?
所有的事情必须在TextChanged事件被解雇.. 这里是我的代码: -
void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 1)
{
TextBox tb = (TextBox)e.Control;
tb.TextChanged += new EventHandler(tb_TextChanged);
}
}
void tb_TextChanged(object sender, EventArgs e)
{
//listBox1.Visible = true;
//string firstChar = "";
//this.listBox1.Items.Clear();
//if (dataGridView1.CurrentCell.ColumnIndex == 1)
{
string str = dataGridView1.CurrentRow.Cells["Column2"].Value.ToString();
if (str != "")
{
MessageBox.Show(str);
}
}
'字符串enteredText =((文本框)发送器)。文本;'是等价的。 – ThunderGr