Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Does anyone know how I canconly enable a
datagridview's cell click event only on the 3rd
column. So it will only trigger when the 3rd
column is clicked?

Any help would be appriciated!!

I have a remove button on the 3rd column,
so it has to only remove the row when the
button (3rd) row is clicked.

(Its not a problem removing the row. Thats
working fine)
Posted
Updated 7-Sep-11 13:21pm
v2
Comments
Wonde Tadesse 7-Sep-11 20:22pm    
Please tag your question properly ? Is it WPF, WinForm ...
Dr.Walt Fair, PE 7-Sep-11 21:03pm    
How are you putting the button on the cell. That may be the key to capturing its click event.

1 solution

If your using WinForms DataGridView you can use the event handler shown.

C#
private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
        if (e.ColumnIndex == 2)  //3rd Column
       {
             .... Do something .....
       }
}


This will only look at the 3rd column and ignore the rest.
Just a shot hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900