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

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.

1 Reply

MU Murugan Syncfusion Team May 15, 2007 11:39 PM UTC

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

Loader.
Up arrow icon