Button with arrowdown (acting as a combobox) - Soeren D.

22-Jun-07 08:28:57
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
reply
 
 

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
reply
 

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
reply
 

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
reply
 

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.
reply
 
How can i use the editor attribute?
promotion
Silverlight    WPF    WCF    WWF    LINQ   
JavaScript    AJAX    ASP.NET    XAML   
C#    VB.NET    VB 6.0    GDI+    IIS    XML   
.NET Generics    Anonymous Methods    Delegate   
Visual Studio .NET    Expression Blend    Virus   
Windows Vista    Windows XP    Windows Update   
Windows 2003 Server    Windows 2008 Server   
SQL Server    Microsoft Excel    Microsoft Word   
SharePoint    BizTalk    Virtual Earth   
.NET Compact Framework    Web Service   

"Everything" RSS / ATOM Feed Parser
How to send and receive messages through message queuing in .Net
How to Read text file as database
SQL Server 2005 Paging Performance Tip
Display code of web page.
Fully Scalable Excel File Importer class for .net using Microsoft Jet driver
Generic Chart Color Manager class that can be used for any charts
Helper class to style the infragistics wingrid
Using Reflection to detemine as Assembly Info in and out.
Helper class to play with Window (Owners and position)
Resolving displayname from the culture using the XmlLanguage and LanguageSpecificStringDictionary class