Datagridview cellcontent click event not working properly

Total Post:108

Points:756

C# 
C#
 1793  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. 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

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.