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

ComboDropDown background color

I downloaded a sample from the forum to create a derived control from ComboDropDown and assign the ColorUIControl as the PopupControl. In the ColorSelected event of the ColorUIControl, the BackColor property of the ComboDropDown is changed to reflect the newly-selected color. Also, DrawListModeEditPortion is overridden and contains the following code : base.DrawListModeEditPortion(e, Color.Empty, Color.Empty, true); This works fine except that I need to set FlatStyle to System so that this combobox looks like the rest of the ones in my application. When set to System, the background color reverts to white as soon as the control loses focus. How do I override the other Draw routines that are part of the ComboDropDown so that they draw the same FlatStyle.System border but use the background color that I''ve put in BackColor?

5 Replies

AD Administrator Syncfusion Team August 9, 2004 06:19 PM UTC

Hi Lori, I have created a test sample as per your specifications, and it seems to be working fine when the ComboDropDown''s FlatStyle is set to System. Please refer to the test sample attached here and let me know if I have understood your requirements correctly. If not, kindly modify the sample to show the problem that you are facing and send it back to us so that we could further investigate it. We appreciate your cooperation, and thanks for chosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.


LS Lori S. Pearsall August 9, 2004 07:03 PM UTC

Hi Guru, Add this statement to your combobox initialization : this.comboDropDown1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; >Hi Lori, > >I have created a test sample as per your specifications, and it seems to be working fine when the ComboDropDown''s FlatStyle is set to System. Please refer to the test sample attached here and let me know if I have understood your requirements correctly. If not, kindly modify the sample to show the problem that you are facing and send it back to us so that we could further investigate it. We appreciate your cooperation, and thanks for chosing Syncfusion products. > >Regards, >Guru Patwal >Syncfusion, Inc.


AD Administrator Syncfusion Team August 10, 2004 09:26 PM UTC

Hi Lori, Thanks for the update. I could observe this behavior here, when the ComboDropDown''s DropDownStyle is set to DropDownList. I will further investigate this issue, and get back to you as soon as possible. We appreciate your patience and cooperation. Regards, Guru Patwal Syncfusion, Inc.


AD Administrator Syncfusion Team August 12, 2004 11:25 AM UTC

Hi Lori, Please derive from the ComboDropDown control and override the DrawBorderAndBackground method as shown below : public class CustomComboDropDown : ComboDropDown { SolidBrush brush = new SolidBrush(Color.White); public CustomComboDropDown() : base() { } public SolidBrush SelectedColorBrush { get { return brush; } set { brush = value; } } protected override void DrawBorderAndBackground(Graphics g, Rectangle rect) { base.DrawBorderAndBackground(g, rect); g.FillRectangle(brush,rect.X+1, rect.Y+1, rect.Width-2, rect.Height-2); } } Please refer to the sample attached here that illustrates this and let me know if it meets your requirements. Thanks for choosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.


LS Lori S. Pearsall August 12, 2004 06:31 PM UTC

Hi Guru, That''s what I was looking for - thanks!!

Loader.
Live Chat Icon For mobile
Up arrow icon