What is the ComboBox DropDown button v font

  • Thread starter Thread starter Academia
  • Start date Start date
A

Academia

I'm making my own ComboBox and would like the DropDown button to look like
the system combo box.

Do you know the Font for the "v" that is used in the regular combobox.

Is that the letter vee or some other character?

I think I can use the system button face color. Is that correct?



Thanks
 
Academia said:
I'm making my own ComboBox and would like the DropDown button to look like
the system combo box.

'ControlPaint.DrawComboButton'.
 
Herfried K. Wagner said:
'ControlPaint.DrawComboButton'.

Guess I can go home now that I learned something today. Wonder how many
other classes exist that help that I don't know about. Thanks
LS
 
I couldn't get it to work.
I checked and a Button has ControlStyles.UserPaint equal to False.


Thanks for trying
 
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 said:
I couldn't get it to work.
I checked and a Button has ControlStyles.UserPaint equal to False.


Thanks for trying
 
I didn't realize I had to create a new class.
In fact I did cteate one to learn ControlStyles.UserPaint equals to False

Thanks


Brendon Bezuidenhout said:
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>
 
Works well but I guess there is something else I don't know.
With the code like this
' If Not ComboBoxRenderer.IsSupported Then

ControlPaint.DrawComboButton(e.Graphics, Me.ClientRectangle, buttonState)

'Else

'ComboBoxRenderer.DrawDropDownButton(e.Graphics, Me.ClientRectangle,
comboBoxState)

'End If

The button look like the rest of my app's combo buttons.

But with the comment marks removed the Else code is executed and the button
looks like those of Visual Studio's combo buttons.

Guess there must be a way of setting VS so that

"visual styles are applied to the client area of application windows"

mentioned in the ComboBoxRenderer Class help.

If I did learn how to make my app have "visual styles" like my VS has what
operating systems do not support it?


Thanks



Brendon Bezuidenhout said:
Actually Herfried is correct FYI - Create a new class and insert the
following code *hears the appology to Herfried in the background*

SURE.
Actually I expected him to tell me why MY statement was wrong.
Instead you did.

Thanks again



- 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>
 
Vista - You need to use the Win32 API's to paint using Aero etc so far as
I've been able to find out... but getting to do it is another story I'm
still trying to do *cry*

The IF block is to make sure it paints on either XP or pre XP Windows
 
Please bear with me. I want to be sure I understand.

ComboBoxRenderer is supported on XP and Vista but NOT on pre-XP Wimdows.
But ControlPaint is supported on pre-XP Windows and post-XP Windows..


Right?


Thanks
 
ControlPaint AND the renderer for controls are supported by XP - Pre XP days
only supports the ControlPaint - Last time I checked at least... An error
will be thrown in the pain when you attemt to use ControlPaint when a
renderer interface is not supported...
 
thanks

Brendon Bezuidenhout said:
ControlPaint AND the renderer for controls are supported by XP - Pre XP
days only supports the ControlPaint - Last time I checked at least... An
error will be thrown in the pain when you attemt to use ControlPaint when
a renderer interface is not supported...
 
Back
Top