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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridListControl Woes 2

Thread ID:

Created:

Updated:

Platform:

Replies:

19568 Sep 29,2004 10:42 AM UTC Sep 30,2004 05:25 AM UTC WinForms 6
loading
Tags: GridControl
Raul Rosenthal
Asked On September 29, 2004 10:42 AM UTC

I''d like to change the color of the grid that appears in the combobox. I tried the following code: private void grdBound_CurrentCellShowingDropDown(object sender, Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs e) { GridCurrentCell cc = grdBound.CurrentCell; if ( grdBound[cc.RowIndex, cc.ColIndex].CellType == "GridListControl" ) { GridDropDownGridListControlCellRenderer cr = ( GridDropDownGridListControlCellRenderer ) cc.Renderer; cr.ListControlPart.BackColor = Color.FloralWhite; // or, alternatively //cr.ListControlPart.Grid.BackColor = Color.FloralWhite; } } The grid appears indeed with the color I set, but only until the user selects a item from the list and then moves to another cell. Next time the combo drops down, it appears with a white backcolor. Now I am using v2.1.0.9, to make sure that it is not a bug in v1.6.1.8. Is it a bug or am I missing something? Thank you. Raul Rosenthal

Administrator [Syncfusion]
Replied On September 29, 2004 11:18 AM UTC

I do not see this behavior in the attached sample. The color red ''sticks'' on the dropdown in line 35 in this sample using 2.1.0.9 for me. Do you see the problem in this sample? If you place a Console.WriteLine in the CurrentCellShowingDropDown event, is the code setting the color being hit with the second drop? Can you post a little sample project showing the problem? VB_8429.zip

Raul Rosenthal
Replied On September 29, 2004 11:40 AM UTC

Your sample works fine. I tried to find any differences between your code and mine and found the culprit in the following event handler, that I added to your sample. Private Sub gridControl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gridControl1.Click gridControl1.RowStyles(gridControl1.CurrentCell.RowIndex).BackColor = Color.AliceBlue End Sub With this code, your sample has the same behaviour as mine, but I don''t understand why and how I could avoid it. Can you help? Thanks. Raul Rosenthal

Administrator [Syncfusion]
Replied On September 29, 2004 12:00 PM UTC

In the sample I was able to work around this problem by moving the code that colors the current row from the Click event to the PrepareViewStyleInfo event (setting the color on demand there for each cell in the current row) and setting this property initially. Me.gridControl1.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow
Private Sub gridControl1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles gridControl1.PrepareViewStyleInfo
            If e.RowIndex = gridControl1.CurrentCell.RowIndex Then
                e.Style.BackColor = Color.AliceBlue
            End If
        End Sub

Raul Rosenthal
Replied On September 29, 2004 12:30 PM UTC

You''re right. But I have to change the color of the cell depending on some checks that are performed after user input (i.e. I set the backcolor to red if the data in not congruent with the content of other cells in the grid.) But, can you confirm that this behaviour is a bug? If so I can wait for a fix and leave the combo white for now.

Administrator [Syncfusion]
Replied On September 29, 2004 02:46 PM UTC

In the original sample (using Click instead of PrepareViewStyleInfo), if you click on a non-gridlistcontrol cell, and then try to drop the gridlistcontrol in that row, the color is not correct for even the first drop. I think what is happening here that the RowStyle setting are being applied after the CurrentCellShowingDropDown occurs, and this is why the RowStyle color is taking precedence over the one you set in the event. If you look closely, on occasion, I can actually see the red show before the blue paints over it. So, it is not clear that this is something we will try to change right away if at all. Changing the order in which events are hit is a tricky thing to do, and will likely break existing code. If you cannot use the main grid''s PrepareViewStyleInfo event to set the color of the selected row, then another solution would be to keep the click event, but also subscribe to the render.ListBoxPart.Grid.PrepareViewStyleInfo event setting the dropdown color there. This should take precedence over the rowstyle setting. Dim cr As GridDropDownGridListControlCellRenderer = gridControl1.CellRenderers("GridListControl") cr.ListControlPart.ShowColumnHeader = False AddHandler cr.ListControlPart.Grid.PrepareViewStyleInfo, AddressOf gridControl1_PrepareViewStyleInfo
Private Sub gridControl1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As GridPrepareViewStyleInfoEventArgs)
            e.Style.BackColor = Color.Red
End Sub

Raul Rosenthal
Replied On September 30, 2004 05:25 AM UTC

Ok, I''ll try this route. Meanwhile, I found that setting the backcolor of the cell to Color.Transparent does not affect color of the grid in the combo. So now when the cell is marked red to hilight an error, the combo appears red, otherwise it appears in the correct color. I can live with it. Thank you.

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.

Warning Icon 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.Close Icon

;