We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridDataBoundGrid Cell BackColor Issues

Thread ID:

Created:

Updated:

Platform:

Replies:

14781 Jun 3,2004 06:09 PM Jun 5,2004 07:19 AM Windows Forms 3
loading
Tags: GridControl
Andrew
Asked On June 3, 2004 06:09 PM

Hello, I am trying to change the backcolor of the header row on my GridDataBoundGrid using the following code: Private Sub Header_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As GridPrepareViewStyleInfoEventArgs) If e.ColIndex > 1 And e.RowIndex = 0 Then e.Style.BackColor = System.Drawing.Color.AliceBlue grdResults.Refresh() End If End Sub Unfortunately, this method is not working for me. I know the code above is being executed because when I insert breakpoints at each line they''re hit during execution. Is there something that I am forgetting to do? I''m using Essential Suite 2.0.5.1 Thanks, Andrew

Administrator [Syncfusion]
Replied On June 4, 2004 02:02 AM

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

Administrator [Syncfusion]
Replied On June 5, 2004 07:05 AM

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 > >

Administrator [Syncfusion]
Replied On June 5, 2004 07:19 AM

You can just comment out your QueryColWidths handler to see if that is affecting your PrepareViewStyleInfo code. I suspect not, but don''t know for sure. Where/when is your searchRetail method being called. It is adding columns to the grid and also hiding a column. This may affect column numbering if you are checking for column numbers in PrepareViewStyleInfo, you should take into account these changes. If you can post a sample project showing the problem, maybe we can spot something here.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;