Hi,

I have a dataGridView that has 2 columns called (style & type) and I want to have a click event that only fires on the (type) column.

I can code it so it works on both but for my app that is a little untidy.

I have searched a bit on the net and seen various ways to do this via row index but nothing by column index.

Any help would be appreciated..,

MT ;)

Hi,

I have a dataGridView that has 2 columns called (style & type) and I want to have a click event that only fires on the (type) column.

I can code it so it works on both but for my app that is a little untidy.

I have searched a bit on the net and seen various ways to do this via row index but nothing by column index.

Any help would be appreciated..,

MT ;)

I finally sorted it out like this:-

dataGridView1.CellContentClick += delegate(object s, DataGridViewCellEventArgs e3)
            	 {
            	if (e3.ColumnIndex ==1){
            		MessageBox.Show(string.Format("Row #{0}, Column #{0} Clicked", e3.RowIndex, e3.ColumnIndex));
            	}}

I have placed a MessageBox there just to see it working and it does.

The Click event is only triggered when an entry in the second column is selected.

Regards..,

MT ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.