Actually Herfried is correct FYI - Create a new class and insert the
following code *hears the appology to Herfried in the background* - I'll
leave you to fill the comments out as it's pretty self explanitory for
someone who's trying to create their own ComboBox :)
Brendon
<code>
/// <summary>
///
/// </summary>
public class cboButton : Button
{
#region Fields
private ButtonState buttonState;
private ComboBoxState comboBoxState;
#endregion
#region Constructor
/// <summary>
/// Custom
/// </summary>
public cboButton()
{
SetControlStyles();
}
#endregion
#region Protected override methods
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnMouseUp(MouseEventArgs e)
{
buttonState = ButtonState.Normal;
comboBoxState = ComboBoxState.Normal;
base.OnMouseUp(e);
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnMouseDown(MouseEventArgs e)
{
buttonState = ButtonState.Pushed;
comboBoxState = ComboBoxState.Pressed;
base.OnMouseDown(e);
}
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (!ComboBoxRenderer.IsSupported)
{
ControlPaint.DrawComboButton(e.Graphics,
this.ClientRectangle, buttonState);
}
else
{
ComboBoxRenderer.DrawDropDownButton(e.Graphics,
this.ClientRectangle, comboBoxState);
}
}
#endregion
#region Private methods
/// <summary>
///
/// </summary>
private void SetControlStyles()
{
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
}
#endregion
/// <summary>
///
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// cboButton
//
this.UseCompatibleTextRendering = true;
this.ResumeLayout(false);
}
}
</code>
"Academia" <ac************@a-znet.comwrote in message
news:uQ**************@TK2MSFTNGP06.phx.gbl...
>I couldn't get it to work.
I checked and a Button has ControlStyles.UserPaint equal to False.
Thanks for trying
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:uG**************@TK2MSFTNGP06.phx.gbl...
>"Academia" <ac************@a-znet.comschrieb:
>>I'm making my own ComboBox and would like the DropDown button to look
like the system combo box.
'ControlPaint.DrawComboButton'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>