System.Windows.Forms.PaintEventArgs
(1)
SystemBrushes.ControlText
(1)
ToolStripDropDownButton
(1)
SystemBrushes
(1)
MeasureString
(1)
DrawString
(1)
Component
(1)
Button
(1)

Button with arrowdown (acting as a combobox)

Asked By Soeren D.
22-Jun-07 08:28 AM
I have seen WinForm applications with a control, that I am pretty sure is
standard in .NET 2.0

It is a button with a leftadjusted text followed by an arrow pointing down.
When the button is pressed, a menu is shown benieth and the text of the
selected menuitem becomes the new buttontext.

From a functional point of view it is a combobox, but this design is
wellsuited for my application.

Do you know where to find it?

Thanks in advance.

Best regards
Soeren

There is a ToolStripDropDownButton class that does this.

Asked By Kevin Spencer
22-Jun-07 11:26 AM
There is a ToolStripDropDownButton class that does this.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

Hi Kevin,I tried to look it up but is appears to be for toolstrips only and I

Asked By Soeren D.
22-Jun-07 12:08 PM
Hi Kevin,

I tried to look it up but is appears to be for toolstrips only and I would
like to use it in the form itself.

But thanks for the tip.

Best regards
Soeren

In that case, create a button that has an arrow on it, and put it next to

Asked By Kevin Spencer
25-Jun-07 06:25 AM
In that case, create a button that has an arrow on it, and put it next to
another button.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
Button with arrowdown (acting as a combobox)
Asked By Jeff Johnson
26-Jun-07 05:15 PM
A while back I needed a "More/Less" button which expanded or collapsed a
form, and I wanted a nice up/down arrow for it as opposed to the more common
like this:

private void MoreInfoButton_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
Font f = new Font("Marlett", MoreInfoButton.Font.Size * 1.1f);
string Arrow;
float TextWidth;

if (_expanded)
Arrow = "5";
else
Arrow = "6";

TextWidth = g.MeasureString(MoreInfoButton.Text,
MoreInfoButton.Font).Width;
g.DrawString(Arrow, f, SystemBrushes.ControlText, TextWidth - 6,
(e.ClipRectangle.Height - g.MeasureString(Arrow, f).Height) / 2);
}

There's some "fudge factor" numbers going on there which were necessary (if
I remember right) because Graphics.MeasureString() wasn't returning a 100%
correct result. However, this was written in .NET 1.1 and maybe this has
changed in 2.0.

As for the dropdown, you could simply create a ContextMenu[Strip] and
display it directly below your button when clicked.
Post Question To EggHeadCafe