|
-
Jun 11th, 2005, 02:45 PM
#1
-
Jun 11th, 2005, 03:16 PM
#2
Addicted Member
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
Why don't you try with:
VB Code:
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
If e.Button Is ToolBarButton1 Then
ContextMenu1.Show(control, position)
End If
End Sub
HTH!
Nebo
It has been said that something as
small as the flutter of a butterfly's
wing can ultimately cause a typhoon
halfway around the world...

-
Jun 11th, 2005, 03:21 PM
#3
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
yeah but as I said I dont know how to determine the position of the button within the toolbar that's the main problem
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Jun 11th, 2005, 04:27 PM
#4
Addicted Member
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
Here's the solution 
VB Code:
Dim pos As Point
pos = ToolBar1.MousePosition
If e.Button Is ToolBarButton1 Then
ContextMenu1.Show(ToolBar1, ToolBar1.PointToClient(pos))
End If
It has been said that something as
small as the flutter of a butterfly's
wing can ultimately cause a typhoon
halfway around the world...

-
Jun 11th, 2005, 04:38 PM
#5
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
Hi,
The way I do it is to assume that the button is of standard width (becaue most of my buttons are) and subdivide the toolbar into several pieces by the unusually shaped buttons (dropdowns, separators etc). I then check the rectangle.X property to determine which separators I am between at the present time and use it to display a description in the status bar:
VB Code:
Dim mousex As Integer = e.X
If mousex < tools.Buttons(1).Rectangle.X Then
statusbar.Panels(0).Text = "Some description"
ElseIf mousex > (tools.Buttons(1).Rectangle.X + tools.Buttons(1).Rectangle.Width) And mousex < tools.Buttons(6).Rectangle.X Then
statusbar.Panels(0).Text = tools.Buttons(Int((mousex - (tools.Buttons(1).Rectangle.X + tools.Buttons(1).Rectangle.Width)) / tools.Buttons(0).Rectangle.Width) + 2).description
ElseIf mousex > (tools.Buttons(6).Rectangle.X + tools.Buttons(6).Rectangle.Width) And mousex < tools.Buttons(12).Rectangle.X Then
statusbar.Panels(0).Text = tools.Buttons(Int((mousex - (tools.Buttons(6).Rectangle.X + tools.Buttons(6).Rectangle.Width)) / tools.Buttons(0).Rectangle.Width) + 7).description
ElseIf
'blahblahblah
Else
statusbar.Panels(0).Text = ""
End If
End If
Here I have a separator as buttons(1), buttons(6), buttons(12) etc. Basically, it says:
If mouse X > separator 1 and mouse X < separator 2 Then
Get the difference between mouse X and the right hand edge of the separator
Divide this by the standard button width to give a number between 0 and the number of buttons in this part of the toolbar
Add on the offset because the separator is at position 6 etc.
Stick the description in the statusbar.
You could do similar, but display the context menu only if you're over the correct button.
HTH
zaza
EDIT: Hey, I like that PointToClient thing. Looks handy.
Last edited by zaza; Jun 11th, 2005 at 04:45 PM.
-
Jun 11th, 2005, 04:52 PM
#6
Addicted Member
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
Huh, looks complicated....
I like PointToClient too
It has been said that something as
small as the flutter of a butterfly's
wing can ultimately cause a typhoon
halfway around the world...

-
Jun 11th, 2005, 06:52 PM
#7
-
Jun 11th, 2005, 07:17 PM
#8
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
Here is how it would do it.
VB Code:
Private Sub tbbNavigation_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbbNavigation.ButtonClick
Select Case Me.tbbNavigation.Buttons.IndexOf(e.Button)
Case 1
'Back
Me.ContextMenu1.Show(Me.tbbNavigation, New Point(e.Button.Rectangle.Left, e.Button.Rectangle.Bottom))
Case 2
'Next
Case 3
'Home
Case 4
'Search
End Select
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 11th, 2005, 09:21 PM
#9
-
Jun 11th, 2005, 09:31 PM
#10
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
..
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2005, 05:13 AM
#11
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
button.Rectangle gives the location
Er...that was my "complicated" method too
Although I trap mine in the mousemove event so I can't use the e.button.
Nice code though, RD.
zaza
-
Jun 12th, 2005, 10:11 AM
#12
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
Thanks zaza. I think I am making the transition from VB6 to VB.NET allot better now after, what, 6 months.
Still, I have a long way to go.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2005, 01:04 PM
#13
Re: Toolbar DropDownButton doesnt show dropdown if you click on the botton?
 Originally Posted by zaza
Er...that was my "complicated" method too
Although I trap mine in the mousemove event so I can't use the e.button.
Nice code though, RD.
zaza
sorry I read the first few lines and I thought that you're assuming a fixed width for each button so I didnt look at the code
thaks to all anyways
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|