0

当我选择一行但 dataGridView1_CellClick 事件未触发时触发 dataGridView1_SelectionChanged 事件。我只使用一个网格。

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
            {

            }
        }
    }

上述事件正确触发。但下面提到的事件不会触发。

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;
        }
    }
4

1 回答 1

0

我有同样的问题。在 SelectionChanged 事件处理程序中对 DataGridView 的 CurrentCell 进行了分配:

_DataGridView.CurrentCell = cellToSelect;

在我删除此分配后,再次触发了 CellClick 事件。

于 2015-05-20T12:56:46.723 回答