VB.NET - 隐藏 datagridview 的左上角单元格
VB.NET - Hide the top left corner cell of a datagridview
我有一个 3 行 2 列的数据网格视图。我的行和列有 headers.
问题是我的 datagridview 左上角有一个空单元格。我认为它是我的行 header 的列 header 或类似的东西。我没有成功隐藏这个单元格,这可能吗?
谢谢
示例:
hide this cell | colHead1| colHead2 |
--------------------------------------
firstname | x | y |
lastname | x1 | y1 |
society | x2 | y2 |
编辑:
我试图将 属性 dtgv.TopLeftHeaderCell.Visible
设置为 False,但它是只读的。
我撤销我的评论。您可以 手动完成此操作。例如,在 bland/unmodified DataGridView
中的 DataGridView.CellPainting
事件处理程序中,您可以像这样匹配背景:
If e.RowIndex < 0 AndAlso e.ColumnIndex < 0 Then
Using brush As New SolidBrush(Me.dataGridView1.BackgroundColor)
e.Graphics.FillRectangle(brush, e.CellBounds)
End Using
e.Handled = True
End If
i would like to show the background of the form
如果您想将 DataGridView
背景设置为表单的背景,用户 Deumber and letsdance 的这两个 (C#) 答案演示了将表单图像的正确部分裁剪到其中的一般设置DataGridView
。使用他们的方法(不调用 SetCellsTransparent()
)加上对 DataGridView.CellPainting
事件处理程序的以下更改应该有效:
If e.RowIndex < 0 AndAlso e.ColumnIndex < 0 Then
e.Graphics.FillRectangle(Brushes.Transparent, e.CellBounds)
e.Handled = True
End If
我有一个 3 行 2 列的数据网格视图。我的行和列有 headers.
问题是我的 datagridview 左上角有一个空单元格。我认为它是我的行 header 的列 header 或类似的东西。我没有成功隐藏这个单元格,这可能吗?
谢谢
示例:
hide this cell | colHead1| colHead2 |
--------------------------------------
firstname | x | y |
lastname | x1 | y1 |
society | x2 | y2 |
编辑:
我试图将 属性 dtgv.TopLeftHeaderCell.Visible
设置为 False,但它是只读的。
我撤销我的评论。您可以 手动完成此操作。例如,在 bland/unmodified DataGridView
中的 DataGridView.CellPainting
事件处理程序中,您可以像这样匹配背景:
If e.RowIndex < 0 AndAlso e.ColumnIndex < 0 Then
Using brush As New SolidBrush(Me.dataGridView1.BackgroundColor)
e.Graphics.FillRectangle(brush, e.CellBounds)
End Using
e.Handled = True
End If
i would like to show the background of the form
如果您想将 DataGridView
背景设置为表单的背景,用户 Deumber and letsdance 的这两个 (C#) 答案演示了将表单图像的正确部分裁剪到其中的一般设置DataGridView
。使用他们的方法(不调用 SetCellsTransparent()
)加上对 DataGridView.CellPainting
事件处理程序的以下更改应该有效:
If e.RowIndex < 0 AndAlso e.ColumnIndex < 0 Then
e.Graphics.FillRectangle(Brushes.Transparent, e.CellBounds)
e.Handled = True
End If