I am having trouble finding code that will show me how to
programatically add a series of buttons to a dropdown button. I want
to recreate something like the first button at the top left of the
VB
6 application, that lets you choose the type of project that you want
to build. I can actually get the button to show the dropdown arrow but
I can't add more buttons under it. Here's a code snippit:
'Dim btnVar As Button
Dim lsiVar As ListImage
'The following line may help to locate the bitmaps
ChDir App.Path
' Load the Pics
Load Me.tbrMain(1)
Set lsiVar = Me.imlMain(0).ListImages.Add(1, , LoadPicture("New.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(2, ,
LoadPicture("Open.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(3, ,
LoadPicture("Save.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(4, ,
LoadPicture("Print.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(5, , LoadPicture("Cut.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(6, ,
LoadPicture("Copy.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(7, ,
LoadPicture("Paste.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(8, ,
LoadPicture("Delete.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(9, ,
LoadPicture("Execute.ico"))
Set lsiVar = Me.imlMain(0).ListImages.Add(10, ,
LoadPicture("Nethood.ico"))
Set lsiVar = Me.imlMain(0).ListImages.Add(11, ,
LoadPicture("Excel.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(12, ,
LoadPicture("Directory.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(13, ,
LoadPicture("Document.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(14, ,
LoadPicture("CSV.bmp"))
Set lsiVar = Me.imlMain(0).ListImages.Add(15, , LoadPicture("IE.bmp"))
Me.tbrMain(0).Align = vbAlignTop
Me.tbrMain(0).Appearance = ccFlat
Me.tbrMain(0).BorderStyle = ccNone
Me.tbrMain(0).Style = tbrFlat
' Must all be consecutive numbers!!!!
Set Me.tbrMain(0).ImageList = Me.imlMain(0)
Set btnVar = Me.tbrMain(0).Buttons.Add(1, , , , 1)
btnVar.ToolTipText = "New SQL Script"
Set btnVar = Me.tbrMain(0).Buttons.Add(2, , , , 2)
btnVar.ToolTipText = "Open SQL Script"
Set btnVar = Me.tbrMain(0).Buttons.Add(3, , , , 3)
btnVar.ToolTipText = "Save SQL Script"
Set btnVar = Me.tbrMain(0).Buttons.Add(4, , , , 4)
btnVar.ToolTipText = "Print"
Set btnVar = Me.tbrMain(0).Buttons.Add(5, , , , 5)
btnVar.ToolTipText = "Cut"
Set btnVar = Me.tbrMain(0).Buttons.Add(6, , , , 6)
btnVar.ToolTipText = "Copy"
Set btnVar = Me.tbrMain(0).Buttons.Add(7, , , , 7)
btnVar.ToolTipText = "Paste"
Me.tbrMain(1).Align = vbAlignTop
Me.tbrMain(1).Appearance = ccFlat
Me.tbrMain(1).BorderStyle = ccNone
Me.tbrMain(1).Style = tbrFlat
Set Me.tbrMain(1).ImageList = Me.imlMain(0)
Set btnVar = Me.tbrMain(1).Buttons.Add(1, , , , 9)
btnVar.ToolTipText = "Execute SQL"
Set btnVar = Me.tbrMain(1).Buttons.Add(2, , , , 8)
btnVar.ToolTipText = "Clear SQL"
Set btnVar = Me.tbrMain(1).Buttons.Add(3, , , , 10)
btnVar.ToolTipText = "Change Connection"
' *** This bit is the button that has the drop down (Style=5 is the
4th element) ***
Set btnVar = Me.tbrMain(1).Buttons.Add(4, , , 5, 11)
btnVar.ToolTipText = "Excel Export"
Set btnVar = Me.tbrMain(1).Buttons.Add(5, , , , 13)
btnVar.ToolTipText = "Documentation"
Set btnVar = Me.tbrMain(1).Buttons.Add(6, , , , 12)
btnVar.ToolTipText = "Tables and Fields Listing"
' *** I want these buttons to be under the Excel Export button, not on
their own as they are currently ***
Set btnVar = Me.tbrMain(1).Buttons.Add(7, , , , 14)
btnVar.ToolTipText = "CSV Export"
Set btnVar = Me.tbrMain(1).Buttons.Add(8, , , , 15)
btnVar.ToolTipText = "HTML Export"
...Help!
Thanks.
Craig.