EDIT: trying to excute the following code in Winforms.
I am fetching the data from xml & they are shown in the datagridview using custom class i have created.I have linked every column with DataPropertyName
I want to show datagridview textboxes, buttoncolumn , checkbox in datagrid like the following image.
I am using following event to change the color of the button i have added. For particular element, suppose i am binding dt
to the single row of grid, then
if(dt.val=="true")
{
// change the color of that button
}
i am using following code.
private void Grid_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
DataGridViewColumn dt = Grid.Columns[9]; // 9 is column no
foreach (DataGridViewRow r in Grid.Rows)
{
if (newList[r.Index].val.ToString() == "true") //some condition
{
r.DefaultCellStyle = red; // this turns compete row red
// add something here to make button red of this row
}
else
{
r.DefaultCellStyle = green;
// add something here to make button red of this row
}
}
}
- I am unable to change the color of particular cell button.
- How do i add checkboxes in last row, as i have already added DataGridViewCheckboxColumn but by default grid is not showing any column.