473,799 Members | 3,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownButton without toolbar

Have anyone seen a component or know how to create a button like toolbar
dropdown button without the toolbar (to be used like a normal button)

Regards
Fredrik Melin
Nov 21 '05 #1
4 4641
Fredrik,
Not sure of a pre-built control, however I've used the Click event of a
normal Button to call ContextMenu.Sho w method.

Something like:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim pos As Point = Button1.Locatio n
pos.Y += Button1.Height
Me.ContextMenu1 .Show(Me, pos)
End Sub

Hope this helps
Jay

"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> wrote in message
news:OF******** ******@TK2MSFTN GP09.phx.gbl...
Have anyone seen a component or know how to create a button like toolbar
dropdown button without the toolbar (to be used like a normal button)

Regards
Fredrik Melin

Nov 21 '05 #2
Yes, but I wanted the nice feature with a arrow down for options and to have
a "default" click event, if no menu was selected.


"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Fredrik,
Not sure of a pre-built control, however I've used the Click event of a
normal Button to call ContextMenu.Sho w method.

Something like:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim pos As Point = Button1.Locatio n
pos.Y += Button1.Height
Me.ContextMenu1 .Show(Me, pos)
End Sub

Hope this helps
Jay

"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> wrote in message
news:OF******** ******@TK2MSFTN GP09.phx.gbl...
Have anyone seen a component or know how to create a button like toolbar
dropdown button without the toolbar (to be used like a normal button)

Regards
Fredrik Melin


Nov 21 '05 #3
Fredrik,
I would use either two buttons...

Or I would create a custom control (possibly deriving from Button) & handle
painting & mouse clicks (possibly overriding Control.OnClick ) myself to
decide if the "default" click event should be handled or the ContextMenu
should be displayed...

Post if you want a sample, I can see if I can come up with one later, no
promises...

Hope this helps
Jay

"Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in message
news:Os******** ******@TK2MSFTN GP12.phx.gbl...
Yes, but I wanted the nice feature with a arrow down for options and to
have a "default" click event, if no menu was selected.


"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Fredrik,
Not sure of a pre-built control, however I've used the Click event of a
normal Button to call ContextMenu.Sho w method.

Something like:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim pos As Point = Button1.Locatio n
pos.Y += Button1.Height
Me.ContextMenu1 .Show(Me, pos)
End Sub

Hope this helps
Jay

"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> wrote in message
news:OF******** ******@TK2MSFTN GP09.phx.gbl...
Have anyone seen a component or know how to create a button like toolbar
dropdown button without the toolbar (to be used like a normal button)

Regards
Fredrik Melin



Nov 21 '05 #4
Did a User Control with a little properties, achor of buttons and so on,
that worked nice.
Set ContextMenu & ButtonText as properties, subscribe on CommandButtonCl ick
event to get the button click event.

Thanks Jay for ideas.

Code below for others to use if anyone need it.

Regards
Fredrik Melin

'-------------------------------------------------------------------

Public Class ucDropDownButto n
Inherits System.Windows. Forms.UserContr ol

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents cmdCommand As System.Windows. Forms.Button
Friend WithEvents cmdDropDown As System.Windows. Forms.Button
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.cmdCommand = New System.Windows. Forms.Button
Me.cmdDropDown = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'cmdCommand
'
Me.cmdCommand.A nchor =
CType((((System .Windows.Forms. AnchorStyles.To p Or
System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Left) _
Or System.Windows. Forms.AnchorSty les.Right),
System.Windows. Forms.AnchorSty les)
Me.cmdCommand.L ocation = New System.Drawing. Point(5, 4)
Me.cmdCommand.N ame = "cmdCommand "
Me.cmdCommand.S ize = New System.Drawing. Size(97, 24)
Me.cmdCommand.T abIndex = 0
Me.cmdCommand.T ext = "Create"
'
'cmdDropDown
'
Me.cmdDropDown. Anchor =
CType(((System. Windows.Forms.A nchorStyles.Top Or
System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Right),
System.Windows. Forms.AnchorSty les)
Me.cmdDropDown. Location = New System.Drawing. Point(101, 4)
Me.cmdDropDown. Name = "cmdDropDow n"
Me.cmdDropDown. Size = New System.Drawing. Size(18, 24)
Me.cmdDropDown. TabIndex = 1
Me.cmdDropDown. Text = "V"
'
'ucDropDownButt on
'
Me.Controls.Add (Me.cmdDropDown )
Me.Controls.Add (Me.cmdCommand)
Me.Name = "ucDropDownButt on"
Me.Size = New System.Drawing. Size(122, 31)
Me.ResumeLayout (False)

End Sub

#End Region
Public Event CommandButtonCl icked(ByVal sender As Object, ByVal e As
EventArgs)

Private m_cMenu As ContextMenu

Public Property ButtonText() As String
Get
Return cmdCommand.Text
End Get
Set(ByVal Value As String)
cmdCommand.Text = Value
End Set
End Property

Public Property cMenu() As ContextMenu
Set(ByVal Value As ContextMenu)
m_cMenu = Value
End Set
Get
Return m_cMenu
End Get
End Property

Private Sub cmdDropDown_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdDropDown.Cli ck
Dim pos As Point = cmdDropDown.Loc ation
pos.Y += cmdDropDown.Hei ght
Me.m_cMenu.Show (Me, pos)
End Sub
Private Sub ucDropDownButto n_Click(ByVal sender As Object, ByVal e As
System.EventArg s) Handles cmdCommand.Clic k
RaiseEvent CommandButtonCl icked(sender, e)
End Sub
End Class

"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:ed******** ******@TK2MSFTN GP11.phx.gbl...
Fredrik,
I would use either two buttons...

Or I would create a custom control (possibly deriving from Button) &
handle painting & mouse clicks (possibly overriding Control.OnClick )
myself to decide if the "default" click event should be handled or the
ContextMenu should be displayed...

Post if you want a sample, I can see if I can come up with one later, no
promises...

Hope this helps
Jay

"Fredrik Melin" <me*@n.o.spam.d acsa.net.remove .as.needed> wrote in message
news:Os******** ******@TK2MSFTN GP12.phx.gbl...
Yes, but I wanted the nice feature with a arrow down for options and to
have a "default" click event, if no menu was selected.


"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Fredrik,
Not sure of a pre-built control, however I've used the Click event of a
normal Button to call ContextMenu.Sho w method.

Something like:

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim pos As Point = Button1.Locatio n
pos.Y += Button1.Height
Me.ContextMenu1 .Show(Me, pos)
End Sub

Hope this helps
Jay

"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> wrote in message
news:OF******** ******@TK2MSFTN GP09.phx.gbl...
Have anyone seen a component or know how to create a button like
toolbar dropdown button without the toolbar (to be used like a normal
button)

Regards
Fredrik Melin



Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4808
by: net | last post by:
I know how to make a page open itself at a certain size and location - I use: <html> <head><script language="Javascript"> window.resizeTo(370,220); window.moveTo(10,10); </script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head>
1
4436
by: krian | last post by:
Hi, How can I change the styles of the DropDownList(Select box)..? and also I want to place an image in the place of DropDownButton of Select Box .. How can i done these in DHTML..?. I would like to know an example on Customizing DorpDownButton of the DropDownList or Select Box(Changing DropDownButton border,placing image as background to buttona and background colors..)
102
7403
by: me | last post by:
How do I prevent the save/print/email/mypictures toolbar from popping up when IE users place their cursor over photos at my website? Thank you in advance for your help. Signed, me
0
1613
by: jbbs | last post by:
I have a question regarding on the button and label. i don't know why when the mouse cursor points on the button, i see the button is flirking. is there anyway to make it not behave like that? because i want to highlight the text above the button when i click on it. can anyone help me out . Thank You the code is following: ############################################ # File: toolbar1.py
5
3053
by: nick_faye | last post by:
Hi, I am still a newbie to VB and using MS Access 2000. I am currently trying to provide a preview of reports before printing them. My program is simple: AC.DoCmd.OpenReport "MyReport", acViewPreview AC.Visible = True AC.DoCmd.ShowToolbar "Print Preview", acToolbarNo AC.DoCmd.ShowToolbar "Menu Bar", acToolbarNo
3
5021
by: James Tran | last post by:
I created a toolbar, set the style of my button to be a dropdownbutton, and type in the button name in the text field. After I do this, what happens is that the dropdownbutton automatically grows to about double the original button height (from 22 or 36). If I change the button height back to 22, the name of the dropdownbutton is cutoff. Can someone show me how to fix this problem?
6
3132
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for ToolbarButtons... Does anyone know how this could be done? Looking forward to hear from you,
1
2292
by: audiolover | last post by:
I have searched but cannot find an answer to my question. I hope I put it in the correct forum? I use a musicplayer called Foobar in XP and I would like to change the way it looks. On starting I want the program to open fullscreen without the toolbar or at least the X-button+minimise+maximise removed, the "ALT F4" command should still function. Preferably only with this program but if difficult I have no problem removing the toolbar or...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10470
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10214
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.