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.

Disabling mouseover background change for ComboBoxDropDown and ComboBoxAdv in Ver. 5.1

Thread ID:

Created:

Updated:

Platform:

Replies:

60931 May 15,2007 02:37 PM May 15,2007 07:39 PM Windows Forms 1
loading
Tags: Tools
James Blibo
Asked On May 15, 2007 02:37 PM

How can I disable the mouseover from changing the background color for ComboBoxDropDown and ComboBoxAdv. I want a fix color or want to be able to manually control this behavior to the color I want.

Also, is it possible to hide the down arrow at the far right.

Murugan [Syncfusion]
Replied On May 15, 2007 07:39 PM

Hi James,

How can I disable the mouseover from changing the background color for ComboBoxDropDown and ComboBoxAdv. I want a fix color or want to be able to manually control this behavior to the color I want.

This could be achieved by customizing the ComboBoxAdv control. The dropdown control is a ListControl. To set custom selected color, we have modified the DrawMode property and DrawItem events of the ListControl.

[Code]

public class CustomCombo : ComboBoxAdv
{

public int LastSelectedIndex = -1;
public Brush SelTextBGColor = Brushes.Gray;

public CustomCombo(): base()
{
this.ListBox.DrawMode = DrawMode.OwnerDrawFixed;
this.ListBox.DrawItem += new DrawItemEventHandler(ListBox_DrawItem);
}

void ListBox_DrawItem(object sender, DrawItemEventArgs e)
{
Brush myBrush = Brushes.Black;

if (this.LastSelectedIndex != e.Index && this.LastSelectedIndex != -1 )
{
e.Graphics.FillRectangle(Brushes.White, this.ListBox.GetItemRectangle(this.LastSelectedIndex));
e.Graphics.DrawString(this.ListBox.Items[this.LastSelectedIndex].ToString(), e.Font, myBrush, this.ListBox.GetItemRectangle(this.LastSelectedIndex), StringFormat.GenericDefault);
}

if (e.Index == this.ListBox.SelectedIndex)
{
e.Graphics.FillRectangle(this.SelTextBGColor, e.Bounds);
}

e.Graphics.DrawString(this.ListBox.Items[e.Index].ToString(), e.Font, myBrush, e.Bounds, StringFormat.GenericDefault);

this.LastSelectedIndex = this.ListBox.SelectedIndex;

}

}

is it possible to hide the down arrow at the far right?
Yes. It is possible to hide the down arrow at the far right by setting the DropDown style property to Normal.

[Code]
this.comboBoxAdv1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;

[Sample]
http://websamples.syncfusion.com/samples/Tools.Windows/F60931/Main.htm

Please refer to this and let me know if it helps you.

Thank you for your interest in Syncfusion products.

Regards,
Murugan P.S

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.

;