EDIT: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
私は、次の画像のようにDataGridviewのテキストボックス、buttoncolumn、チェックボックスを表示したい。

私は追加したボタンの色を変更するために次のイベントを使用しています。特定の要素については、グリッドの1行に dt
をバインドしているとします
if(dt.val=="true")
{
// change the color of that button
}
私は次のコードを使用しています。
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
}
}
}
- 特定のセルボタンの色を変更できません。
- DataGridViewCheckboxColumnを既に追加しているので、最後の行にチェックボックスを追加するにはどうしますか?デフォルトではグリッドには列が表示されません。