Button with arrowdown (acting as a combobox) - Kevin Spencer |
22-Jun-07 11:26:03
|
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 |
 |
| |
Button with arrowdown (acting as a combobox) - Soeren D. |
22-Jun-07 12:08:06
|
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 |
 |
| |
Button with arrowdown (acting as a combobox) - Kevin Spencer |
25-Jun-07 06:25:26
|
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) - Jeff Johnson |
26-Jun-07 05:15:50
|
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. |
 |
| |