I have a datagridview which has its first column of button field. There is another column called "Fee" which can be - ontime or late. I want to disable button for that row in the datagrid which has Fee as "ontime" and enable button when fee is late during the datagrid load or cell formatting event.
What I want is that the button column for row having fee as "ontime" to be disabled when the form loads. And when the fee is "late", button should be enabled so that they can click on it which then will open another form.
I tried the same thing you posted but when the datagrid loaded on the form, I could still click on the button cloumn for which the fee was "ontime" and it opened another form. I don't care if it not greyed but it is not being disabled.
if (dataGridView1.Rows[e.RowIndex].Cells["fee"].Value.ToString() == "ontime")
will pass evaluation. In other words, the value of the "fee" column (or whatever it's called) needs to be either "ontime" or "late" - these are just examples as I don't know the exact values you are assigning them.
Also, my example assumed that the other column was called "button" - this needs to be changed to the correct name if it is not...
Also, try examining the value of the fee column by debugging the CellFormatting eventhandler...