I tried your example and it worked fine on my machine, which leaves me extremely confused. I removed the refresh call from my code and it still does not work. I also have the follwing code that affects the appearance of my grid:
Private Sub GetColWidth(ByVal sender As Object, ByVal e As GridRowColSizeEventArgs)
If Me.m_proportionalGridCell And e.Index = 4 Then
If (CStr(Me.cboCustomerType.SelectedValue) = "R") Then
Dim left As Integer = Me.grdResults.Model.ColWidths.GetTotal(2, 3)
Dim right As Integer = Me.grdResults.Model.ColWidths.GetTotal(5, 7)
e.Size = CInt((Me.grdResults.ClientRectangle.Width) - right - left) - 1
If (e.Size < 200) Then
e.Size = 200
End If
ElseIf (CStr(Me.cboCustomerType.SelectedValue) = "B") Then
Dim left As Integer = Me.grdResults.Model.ColWidths.GetTotal(2, 3)
Dim right As Integer = Me.grdResults.Model.ColWidths.GetTotal(5, 6)
e.Size = CInt((Me.grdResults.ClientRectangle.Width) - right - left) - 1
If (e.Size < 200) Then
e.Size = 200
End If
End If
e.Handled = True
End If
-------------------- AND -----------------------
Private Sub searchRetail()
grdResults.DataSource = m_retail_search_results
Dim gbc As New GridBoundColumn
gbc.MappingName = "CustomerID"
gbc.HeaderText = "Customer ID"
grdResults.Model.Cols.Hidden(1) = True
grdResults.GridBoundColumns.Add(gbc)
gbc = New GridBoundColumn
gbc.MappingName = "FirstName"
gbc.HeaderText = "First Name"
grdResults.GridBoundColumns.Add(gbc)
.
.
.
.
gbc = New GridBoundColumn
gbc.MappingName = "BusinessTelephone"
gbc.HeaderText = "Business Telephone"
grdResults.GridBoundColumns.Add(gbc)
''Initialize Columns
grdResults.Binder.InitializeColumns()
Could either of these code snippets be interferring with my function that changes the BackColor of the header row?
Thanks,
Andrew
>Two comments on your code.
>
>You do not want to do the grid.Refresh call from within PrepareViewStyleInfo. So, try removing it (I think this is what is causing things not to work, but am not 100% sure).
>
>The e.ColIndex > 1 will mean both the rowheader column and the first scrollable column will not be affected.
>
>Here is a little sample.
>
Froum_prepareViewStyleInfo_7471.zip
>
>