0

I pull results from Oracle database and store it in DataTable before setting it as source in DataGridView. The reason for this is I remove some columns before I show it to user. Using DataGridViewButtonColumn I have added column that has enables user to "Edit" specific row. My problem is I'm trying to disable that button based on value in that current row. Leave the rest of the row buttons enabled.

var table = OracleConnection.Results(myquery);
table.Columns.Remove("Comments");
var editButton = new DataGridViewButtonColumn;
editButton.Value = "Edit";
editButton.Text = "Edit";
editButton.UseColumnTextForButtonValue = true;
_dtgvResults.Source = table;
_dtgvResults.Columns.Add(editButton);
abatishchev
  • 98,240
  • 88
  • 296
  • 433
  • This is answered quite comprehensively on MSDN: http://msdn.microsoft.com/en-us/library/ms171619.aspx you basically need to handle the cellvaluechanged event, check the column, then change the cell (plus they add a new property to allow the button to actually appear disabled) – David Hall May 16 '13 at 21:28
  • After looking at example I'm not sure if I want to go through trouble of doing all that just to disable one button. I might just handle the value of row on CellContentClick to figure out if I should proceed or go back. –  May 20 '13 at 12:53
  • After more searching I just decided to change from ButtonColumn to text column and add button somewhere else on the form. Now I just modify the text value when button is clicked. –  Jun 03 '13 at 12:23

1 Answers1

0

Take a look in OnRowDataBound event in your DataGridView

MS Reference

Davi Ruiz
  • 120
  • 3