2013-09-05 64 views
0

dataGridView1_SelectionChanged事件觸發,當我選擇一行但dataGridView1_CellClick事件不觸發。我只使用一個網格。爲什麼在DataGridView中的SelectionChanged事件時CellClick事件不會觸發?

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; 
     } 
    } 
+1

也許是因爲'SelectionChanged'事件附加到'dgvApInvoice'和'CellClick'附加到'mgInvoice'?不一樣的控制?它的公正命名問題? – Reniuz

+0

不是這是一個網格 –

+0

如果真的附加了事件句柄,請仔細檢查設計器文件或通過設計器。不發射你的意思是不打中斷點? – Reniuz

回答

0

我有同樣的問題。有一個分配到DataGridView的SelectionChanged事件處理程序的CurrentCell:

_DataGridView.CurrentCell = cellToSelect; 

之後,我刪除了此任務的CellClick事件再次被解僱。

相關問題