473,396 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 4611
Fredrik,
Not sure of a pre-built control, however I've used the Click event of a
normal Button to call ContextMenu.Show method.

Something like:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pos As Point = Button1.Location
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**************@TK2MSFTNGP09.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***************@TK2MSFTNGP11.phx.gbl...
Fredrik,
Not sure of a pre-built control, however I've used the Click event of a
normal Button to call ContextMenu.Show method.

Something like:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pos As Point = Button1.Location
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**************@TK2MSFTNGP09.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.dacsa.net.remove.as.needed> wrote in message
news:Os**************@TK2MSFTNGP12.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***************@TK2MSFTNGP11.phx.gbl...
Fredrik,
Not sure of a pre-built control, however I've used the Click event of a
normal Button to call ContextMenu.Show method.

Something like:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pos As Point = Button1.Location
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**************@TK2MSFTNGP09.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 CommandButtonClick
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 ucDropDownButton
Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

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

'Add any initialization after the InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'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.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.cmdCommand = New System.Windows.Forms.Button
Me.cmdDropDown = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'cmdCommand
'
Me.cmdCommand.Anchor =
CType((((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.cmdCommand.Location = New System.Drawing.Point(5, 4)
Me.cmdCommand.Name = "cmdCommand"
Me.cmdCommand.Size = New System.Drawing.Size(97, 24)
Me.cmdCommand.TabIndex = 0
Me.cmdCommand.Text = "Create"
'
'cmdDropDown
'
Me.cmdDropDown.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.cmdDropDown.Location = New System.Drawing.Point(101, 4)
Me.cmdDropDown.Name = "cmdDropDown"
Me.cmdDropDown.Size = New System.Drawing.Size(18, 24)
Me.cmdDropDown.TabIndex = 1
Me.cmdDropDown.Text = "V"
'
'ucDropDownButton
'
Me.Controls.Add(Me.cmdDropDown)
Me.Controls.Add(Me.cmdCommand)
Me.Name = "ucDropDownButton"
Me.Size = New System.Drawing.Size(122, 31)
Me.ResumeLayout(False)

End Sub

#End Region
Public Event CommandButtonClicked(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_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdDropDown.Click
Dim pos As Point = cmdDropDown.Location
pos.Y += cmdDropDown.Height
Me.m_cMenu.Show(Me, pos)
End Sub
Private Sub ucDropDownButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdCommand.Click
RaiseEvent CommandButtonClicked(sender, e)
End Sub
End Class

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ed**************@TK2MSFTNGP11.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.dacsa.net.remove.as.needed> wrote in message
news:Os**************@TK2MSFTNGP12.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***************@TK2MSFTNGP11.phx.gbl...
Fredrik,
Not sure of a pre-built control, however I've used the Click event of a
normal Button to call ContextMenu.Show method.

Something like:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pos As Point = Button1.Location
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**************@TK2MSFTNGP09.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
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...
1
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...
102
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
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?...
5
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",...
3
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...
6
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.