DATAGRIDVIEW CELLCONTENT CLICK EVENT NOT WORKING PROPERLY

john rob

Total Post:108

Points:756
Posted by  john rob
C# 
C#
 1296  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. Pravesh Singh

    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

       }

    }

Answer

NEWSLETTER

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