G
Guest
I am have a data grid view, with 2 columns for each day of the week:
Monday | Monday | Tuesday | Tuesday| etc
Hours | Tasks | Hours | tasks |
___________________________________|
3 | 4 | 5 |7 |
2 | 3 | 4 |6 |
It would be nice if the header could split accross 2 cells, like this,
Monday | Tuesday | etc
Hours | Tasks | Hours | tasks |
___________________________________|
3 | 4 | 5 |7 |
2 | 3 | 4 |6 |
I see that datagridview columns have an AdjustCellBorderStyle() function,
but the documentation seems to suggest that you have to override this
function to use it.
I tried the example here:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridviewadvancedborderstyle.aspx
and successfully got custom header cell borders, but since
Public Overrides Function AdjustColumnHeaderBorderStyle
is a function in the CustomDataGridView class, ALL my Header cells use the
custom settings.
I tried adding the function to the DataGridViewCustomColumn Class, but
DataGridViewColumn does not have such a function to override.
however the DataGridViewColumnHeaderCell does have , so I tried this:
Public Class DataGridViewCustomColumn
Inherits DataGridViewColumn
Public Sub New()
Me.CellTemplate = New DataGridViewCustomCell()
Me.HeaderCell = New DataGridViewCustomHeaderCell
End Sub
End Class
Public Class DataGridViewCustomHeaderCell
Inherits DataGridViewColumnHeaderCell
Public Overrides Function AdjustCellBorderStyle( _
ByVal dataGridViewAdvancedBorderStyleInput As
DataGridViewAdvancedBorderStyle, _
ByVal dataGridViewAdvancedBorderStylePlaceHolder As
DataGridViewAdvancedBorderStyle, _
ByVal singleVerticalBorderAdded As Boolean, _
ByVal singleHorizontalBorderAdded As Boolean, _
ByVal firstVisibleColumn As Boolean, _
ByVal firstVisibleRow As Boolean) As
DataGridViewAdvancedBorderStyle
If firstVisibleRow Then
dataGridViewAdvancedBorderStylePlaceHolder.Top = _
DataGridViewAdvancedCellBorderStyle.InsetDouble
Else
dataGridViewAdvancedBorderStylePlaceHolder.Top = _
DataGridViewAdvancedCellBorderStyle.None
End If
dataGridViewAdvancedBorderStylePlaceHolder.Right =
DataGridViewAdvancedCellBorderStyle.None
With dataGridViewAdvancedBorderStylePlaceHolder
.Right = dataGridViewAdvancedBorderStyleInput.Right
.Bottom = dataGridViewAdvancedBorderStyleInput.Bottom
End With
Return dataGridViewAdvancedBorderStylePlaceHolder
End Function
End Class
This gives no errors, but the AdjustCellBorderStyle function in my
DataGridViewCustomHeaderCell is never called.
What am I missing ?
Monday | Monday | Tuesday | Tuesday| etc
Hours | Tasks | Hours | tasks |
___________________________________|
3 | 4 | 5 |7 |
2 | 3 | 4 |6 |
It would be nice if the header could split accross 2 cells, like this,
Monday | Tuesday | etc
Hours | Tasks | Hours | tasks |
___________________________________|
3 | 4 | 5 |7 |
2 | 3 | 4 |6 |
I see that datagridview columns have an AdjustCellBorderStyle() function,
but the documentation seems to suggest that you have to override this
function to use it.
I tried the example here:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridviewadvancedborderstyle.aspx
and successfully got custom header cell borders, but since
Public Overrides Function AdjustColumnHeaderBorderStyle
is a function in the CustomDataGridView class, ALL my Header cells use the
custom settings.
I tried adding the function to the DataGridViewCustomColumn Class, but
DataGridViewColumn does not have such a function to override.
however the DataGridViewColumnHeaderCell does have , so I tried this:
Public Class DataGridViewCustomColumn
Inherits DataGridViewColumn
Public Sub New()
Me.CellTemplate = New DataGridViewCustomCell()
Me.HeaderCell = New DataGridViewCustomHeaderCell
End Sub
End Class
Public Class DataGridViewCustomHeaderCell
Inherits DataGridViewColumnHeaderCell
Public Overrides Function AdjustCellBorderStyle( _
ByVal dataGridViewAdvancedBorderStyleInput As
DataGridViewAdvancedBorderStyle, _
ByVal dataGridViewAdvancedBorderStylePlaceHolder As
DataGridViewAdvancedBorderStyle, _
ByVal singleVerticalBorderAdded As Boolean, _
ByVal singleHorizontalBorderAdded As Boolean, _
ByVal firstVisibleColumn As Boolean, _
ByVal firstVisibleRow As Boolean) As
DataGridViewAdvancedBorderStyle
If firstVisibleRow Then
dataGridViewAdvancedBorderStylePlaceHolder.Top = _
DataGridViewAdvancedCellBorderStyle.InsetDouble
Else
dataGridViewAdvancedBorderStylePlaceHolder.Top = _
DataGridViewAdvancedCellBorderStyle.None
End If
dataGridViewAdvancedBorderStylePlaceHolder.Right =
DataGridViewAdvancedCellBorderStyle.None
With dataGridViewAdvancedBorderStylePlaceHolder
.Right = dataGridViewAdvancedBorderStyleInput.Right
.Bottom = dataGridViewAdvancedBorderStyleInput.Bottom
End With
Return dataGridViewAdvancedBorderStylePlaceHolder
End Function
End Class
This gives no errors, but the AdjustCellBorderStyle function in my
DataGridViewCustomHeaderCell is never called.
What am I missing ?