我希望能在
我尝试过以下代码:
DataGridViewCell
中央绘制一个小的填充圆。使用矩形也可以达到同样的效果。我假设我必须在CellPainting事件中完成它。我尝试过以下代码:
if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
if (dgv_Cuotas.Columns[e.ColumnIndex].Name == "Seleccionar" && Convert.ToBoolean(dgv_Cuotas.Rows[e.RowIndex].Cells["pagada"].Value) == true)
{
e.CellStyle.BackColor = Color.LightGray; ;
e.PaintBackground(e.ClipBounds, true);
e.Handled = true;
}
}
它会涂满整个单元格,但我只想要一个小圆形或矩形,就像我在下一张图片中展示的那样:
我该怎么做呢?使用DataGridViewImageCell不是一个选项,因为我有一个格式错误。我只能将DataGridViewCheckBoxCell更改为DataGridViewTextboxCell。
编辑: 我可以将其更改为DataGridViewImageCell!!之前发生了什么我不知道,但我仍然无法在那里加载图片。我只得到一个带有红色十字(没有图像图标)的白色正方形。这是我的代码:
dgv_Cuotas.Rows[row.Index].Cells["Seleccionar"] = new DataGridViewImageCell();
dgv_Cuotas.Rows[row.Index].Cells["Seleccionar"].Value = Properties.Resources.punto_verde;
dgv_Cuotas.Rows[row.Index].Cells["Seleccionar"].Style.ForeColor = Color.White;
dgv_Cuotas.Rows[row.Index].Cells["Seleccionar"].Style.SelectionForeColor = Color.White;