Toolbar buttons on the fly

G

Guest

Hello,

I'm trying to generate on the fly a toolbar with some buttons.
Unfortunately, even if I install the SP3, toolbar buttons does not display,
only gray squares appear.
Here is my code (the getimage is a method I developped and seems to be
working):

private const int BUTTON_WIDTH = 62;

public static ToolBar CreateToolBar(
Form f,
params string[] buttonText
)
{
ToolBar tb = new ToolBar();
tb.ImageList = new ImageList();
tb.ImageList.ImageSize = new Size(BUTTON_WIDTH, 20);

foreach(string s in buttonText)
tb.ImageList.Images.Add(
GetImage(s)
);

for(int i=0; i<buttonText.Length ; i++)
{
ToolBarButton tbb = new ToolBarButton();

tbb.ImageIndex = i;
tb.Buttons.Add(
tbb
);
}

f.Controls.Add(tb);
return tb;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top