[英]Why CellClick event does not fire when SelectionChanged event in DataGridView?
dataGridView1_SelectionChanged event fire when i select a row but dataGridView1_CellClick event is not firing. dataGridView1_SelectionChanged 事件在我选择一行时触发,但 dataGridView1_CellClick 事件没有触发。 I am using one grid only.
我只使用一个网格。
private void mgInvoice_SelectionChanged(object sender, EventArgs e)
{
if (this.IsFlagForShowImage)
{
////If show image flag is true then only show images for invoices.
try
{
if (this.mgInvoice.SelectedRows != null)
{
if (this.mgInvoice.SelectedRows.Count > 0)
{
invoice = this.mgInvoice.SelectedRows[0].DataBoundItem as TAPInvoice;
Thread th = new Thread(new ThreadStart(LoadDocumentIdByInvoice));
th.Start();
this.ShowInvoiceImageDocumentByDocId(this.invoice);
IsModifiedCollection = true;
//Zahid
this.SetPriviliges();
}
}
}
catch
{
throw;
}
finally
{
}
}
}
the above event fire correctly.上述事件正确触发。 but below mention event does not fire.
但下面提到的事件不会触发。
private void mgInvoice_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (this.mgInvoice.Columns["FImagesReviewed"].Visible)
{
this.mgInvoice.Columns["FImagesReviewed"].Visible = true;
}
else if (this.mgInvoice.Columns["FImagesApproved"].Visible)
{
this.mgInvoice.Columns["FImagesApproved"].Visible = true;
}
}
I had the same problem.我有同样的问题。 There was an assignment to the CurrentCell of the DataGridView in the SelectionChanged event handler:
在 SelectionChanged 事件处理程序中对 DataGridView 的 CurrentCell 进行了分配:
_DataGridView.CurrentCell = cellToSelect;
After I removed this assignment the CellClick event was fired again.删除此分配后,再次触发 CellClick 事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.