DATAGRIDVIEW CELLCONTENT CLICK EVENT NOT WORKING PROPERLY

Total Post:108

Points:756
C# 
C#
 1545  View(s)
Ratings:
Rate this:

I wrote an event to retrieve the first cell value of the clicked cell's row on CellContentClick event in datagridview. but the event is getting raised only when i click the third cell and not getting raised when i click the first or second cell of datagridview.

Please help me.

  1. Post:412

    Points:2888
    Re: Datagridview cellcontent click event not working properly

    Hi John,

    Try to implement the CellClick event instead of CellContentClick event

    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
       DataGridView theGrid = sender as DataGridView;
       if(theGrid != null)
       {
          DataGridViewCell selectedCell = theGrid.SelectedCells[0];
          //Do your logic here
       }
    }

      Modified On Apr-03-2018 06:26:33 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!