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. Image for the cookie policy date

Change color of items in dropdown list

Hi,

I am Syncfusion version 2.0.5.1.

I am using GridControl in my application. I have given one of cells as Combo box type. Also I have given a list of items to be displayed in the dropdown list. I need to change the color of certain items when the combo box is drop down. Kindly let me know how this is possible.

Thanks
Rohith.C

7 Replies

AD Administrator Syncfusion Team November 9, 2006 12:24 PM UTC

Hi Rohith,

Please refer to the below forum thread which discuss with a simillar issue.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=44955

Best Regards,
Haneef


AD Administrator Syncfusion Team November 10, 2006 05:22 AM UTC

Haneef,

Thanks. This sample works. But I need to get this done for only one of the Combo box cell types. I have given the cell type as Combo box for 3 different cells in a row. Even though i register the DrawItem event in gridControl_CurrentCellShowingDropDown only for the particular row and column, the color changes in all the combo boxes. Kindly let me know how to fix this issue.

Thanks
Rohith.C


AD Administrator Syncfusion Team November 10, 2006 06:20 AM UTC

Hi Rohith,

You need to check the CurrentCell.RowIndex and ColIndex in the CurrentCellShowingDropDown event and set ListBoxPart.DrawMode property to DrawMode.Normal. Please try the below code snippet and Let me know if this helps.

Private Sub gridCurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridCurrentCellShowingDropDownEventArgs) Handles grid.CurrentCellShowingDropDown

Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell

Dim cr As GridComboBoxCellRenderer = CType(IIf(TypeOf cc.Renderer Is GridComboBoxCellRenderer, cc.Renderer, Nothing), GridComboBoxCellRenderer)

If Not cr Is Nothing AndAlso cc.RowIndex = 3 AndAlso cc.ColIndex = 2 Then
AddHandler cr.ListBoxPart.SelectedIndexChanged, AddressOf ListBoxPart_SelectedIndexChanged
AddHandler cr.ListBoxPart.DrawItem, AddressOf ListBoxPart_DrawItem
cr.ListBoxPart.DrawMode = DrawMode.OwnerDrawVariable
SavedIndex = -1
Else
cr.ListBoxPart.DrawMode = DrawMode.Normal
End If
End Sub

Best Regards,
Haneef


AD Administrator Syncfusion Team November 10, 2006 09:53 AM UTC

Hi Haneef,

Thanks. Now I the color change reflects only on the combo box in particular row and column. But I am changing colors for some of the items in the combo box. When I select the other items in the Combo box , i need the default behaviour of a combo box. (i.e, the selection color should not be changed). I need to give the default system selction color for that selected item. Also When I select a particular item and then choose the next one (Which is also not colored) the Selection color gets drawn to both the items rather thatn for the last selected one. Kindly let me know how to fix this issue.


AD Administrator Syncfusion Team November 10, 2006 10:24 AM UTC

Hi Haneef,

Herewith I am attaching a sample Application showing the above mentioned scenario. In the sample application in the gridControl, for the 2nd row , i have chosen Combo box types for both 2 and 3rd column. I have changed the Color of some of the items in the combo box for column 2. The column 3 shows the default windows behaviour. Now in the Column 2, for the drop down list , When i select One, and then move down and select 2, Both the items shows the Selected color. Rather I need this combo box to work exactly like in combo box in col 3. I need the same selected color and selection behaviour. The selection color should only show for currently selected item. Not for previous item also.

Thanks
Rohith.C

DropDown2.zip


AD Administrator Syncfusion Team November 10, 2006 10:39 AM UTC

Hi Rohith,

Please try the attached sample and let me know if you are trying something different.
http://www.syncfusion.com/Support/user/uploads/DropDown_a2567a1c.zip

Best Regards,
Haneef


AD Administrator Syncfusion Team November 10, 2006 12:07 PM UTC

Thanks Haneef. It works

Loader.
Live Chat Icon For mobile
Up arrow icon