tags:

views:

163

answers:

1

Hi, i'm developing .NET app. and using some vb6 common controls

in design mode I can create image list and attach it to toolbar control but when I'm programatically adding toolbar buttons

Toolbar.Buttons.Add(, "tbsave", "Save", MSComctlLib.ButtonStyleConstants.tbrDefault, toolbarImages.ListImages(1).Picture)

get exception "Invalid Key" It isn't

Any idea?? Thanks

+1  A: 

You are thinking in .NET. Think in VB6 instead.

dim nIndex as long 
nIndex = 4  ' this is the index of your image in the ImageList control.
            ' The code assumes that you already assigned the ImageList
            ' to the Toolbar.ImageList property

Toolbar.Buttons.Add(, "tbsave", "Save", MSComctlLib.ButtonStyleConstants.tbrDefault, nIndex)
AngryHacker