[英]CellContentClick event doesn't always work
CellContentClick
事件并不总是有效 - 它有时是有效的,有时不是随机的。
我的代码如下,我正在使用断点进行检查,但程序有时会进入块,有时则不会。 为什么会这样?
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
textBoxUserName.ReadOnly = true;
button2.Visible = true;
int index = e.RowIndex;
if (!(index < 0))
{
DataGridViewRow row = dataGridView1.Rows[index];
textBoxUserName.Text = row.Cells["UserNAme"].Value.ToString();
textBoxPassword.Text = row.Cells["Pass"].Value.ToString();
dataGridView1.Focus();
}
dataGridView1.Focus();
}
请尝试使用CellClick事件:
单击单元格的任何部分时发生。
单击单元格时, CellContentClick事件不一定会触发,用户必须单击单元格的“内容”区域,例如文本,例如:
单击单元格中的内容时发生。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.