能否在dataGridView中对某个指定的单元格单独设置样式,比如背景颜色之类。
注:不是指一列或一行是指其中的一个单元格设置颜色。
注:不是指一列或一行是指其中的一个单元格设置颜色。
解决方案 »
- C#连接插入和查询的
- 别人的源码如何导入visual 2008运行呀??
- 如何通过msbuild 或者nant实现自动生成websetup项目
- 【高分求助】C#怎么将Excel文件的数据导入到Access数据库中并对应的字段!!
- vs2008中打包如何运行CMD的命令行和把文件安装到指定目录
- [求助]C#多线程问题
- 请教如何在某应用系统中指定时间无操作后退出系统??(如何用SESSION实现?)
- 宽屏显示窗体的问题 如何使winform窗体显示自适应分辨率
- 多线程的同步问题: lock(??) ??到底应该写什么?
- 请问如何显示gif动画?pictureBox只能显示第一祯而不能显示动画?
- C# WinForm: 如 何 获 取 文 件 占 用 空 间 大 小 (不 是 实 际 大 小) 楼 主 在 线
- 能不能用C#抓取特定网站内容代码?
e.Item.Cells(0).BackColor = System.Drawing.Color.Red
style.BackColor = Color.Red;
dataGridView1.Rows[0].Cells[0].Style = style;
For i As Integer = 0 To 9
Me.DataGridView1.Rows.Add("Row" + i.ToString)
Next
End Sub Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
Dim Rect As Rectangle = New Rectangle(e.CellBounds.X - 1, e.CellBounds.Y + 1, e.CellBounds.Width - 2, e.CellBounds.Height - 2)
If e.RowIndex = 1 And e.ColumnIndex = 0 Then
e.Graphics.DrawRectangle(Pens.Red, Rect)
e.PaintContent(e.CellBounds)
e.Handled = True
End If
End SubEnd Class
protected void gvFile_RowDataBound(object sender, GridViewRowEventArgs e)
{
this.dataGridView1.Rows[i].Cells[j].Style.BackColor = 颜色
}
DataGridViewCellBorderStyle.None;
this.dataGridView1.RowHeadersBorderStyle =
DataGridViewHeaderBorderStyle.Single;
this.dataGridView1.ColumnHeadersBorderStyle =
DataGridViewHeaderBorderStyle.Single;这样可以吗?
e.Graphics.DrawRectangle(Pens.Red, Rect);//绘制矩形。