Commander button in VS2005

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
sring
Newbie
Newbie
Posts: 15
Joined: Thu Jun 30, 2005 4:00 am

Commander button in VS2005

Post by sring » Tue Feb 14, 2006 10:02 pm

I'm updating an application from VS 2003 to 2005, and I have code where I add some buttons to a commander. The buttons are there, and work, but only part of the icons is appearing. It's as if I have a very thin button. Any idea why this is happening?

This is an example of how a button is created

System::Windows::Forms::ToolBarButton ^newButton = gcnew System::Windows::Forms::ToolBarButton();
newButton->ToolTipText = "Add/Edit the plot info";
commander1->ImageList->Images->Add(form1ButtonList->Images[0]);
newButton->ImageIndex = commander1->ImageList->Images->Count -1;
newButtons[13] = newButton;

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Feb 15, 2006 11:39 am

Hi sring,

The commander is based on a System.Windows.Forms.ToolBar. Can you successfully add buttons to an instance of this class?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

sring
Newbie
Newbie
Posts: 15
Joined: Thu Jun 30, 2005 4:00 am

Post by sring » Wed Feb 15, 2006 3:48 pm

Yes, the buttons are there, just partly hidden, it's like there is something in front of them. I have been through all of the components on the form and there doesn't seem to be anything that could account for it. The first extra button, you can see the entire left edge of the image as well as its top. The other buttons, just the top. It's as if there was a rectangle laid over most of the buttons. If you want, I can send you a jpg so that you can see what I mean.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Feb 15, 2006 3:59 pm

Hi sring,

Yes please, post the image at news://www.steema.net/steema.public.attachments newsgroup.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

sring
Newbie
Newbie
Posts: 15
Joined: Thu Jun 30, 2005 4:00 am

Post by sring » Wed Feb 15, 2006 4:30 pm

The image has been posted

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Thu Feb 16, 2006 10:58 am

Hello,

The cause is most likely the Label used to display Commander information (eg. Rotation and Elevation). The Label is private, we'll improve access to it for an upcoming release.

For the moment you could hide it:

eg. (There's only one Label on the Commander)

Code: Select all

foreach (object o in commander1.Controls)
{ if (o is Label)
  ((Label)o).Visible=false;
}
Regards,
Marc Meumann
Steema Support

sring
Newbie
Newbie
Posts: 15
Joined: Thu Jun 30, 2005 4:00 am

Post by sring » Thu Feb 16, 2006 5:00 pm

That fixed it

sring
Newbie
Newbie
Posts: 15
Joined: Thu Jun 30, 2005 4:00 am

Post by sring » Thu Feb 16, 2006 5:34 pm

But, I'm still having a slight problem. The third button that I add always comes out as a black square. I've switched icons back and forth with the fourth button, so I know that the icon can display correctly. Any idea why this would be happening?

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Fri Feb 17, 2006 12:14 pm

Hello,

If I run a test using one of the images already in the list (ie. the '3D' image) to add 5 buttons all the images come out ok. You might like to confirm that:

eg.

Code: Select all

for (int i = 0; i < 5; i++)
{
  System.Windows.Forms.ToolBarButton newButton = new System.Windows.Forms.ToolBarButton();
  newButton.ToolTipText = "My text";
  newButton.ImageIndex = commander1.ImageList.Images.Count - 5;
  ((ToolBar)commander1).Buttons.Add(newButton);
}
Using a new ImageList as per your example, it checks out in the following way:

Code: Select all

for (int i = 0; i < 5; i++)
{
  System.Windows.Forms.ToolBarButton newButton = new System.Windows.Forms.ToolBarButton();
  commander1.ImageList.Images.Add(myImageList.Images[i]);
  newButton.ToolTipText = "my text";
  newButton.ImageIndex = commander1.ImageList.Images.Count - 1;
  ((ToolBar)commander1).Buttons.Add(newButton);
}
Please note that the Commander Image colours are 25x25px, Depth8Bit. In the ImageList I used the colours were 32Bit and colour 'downsizing' takes place. .. I wouldn't think that would have an effect on your image's appearance as it would have moved when you interchanged the icons, but worth bearing in mind. See if a loop similar to the one above gives the same results.

Regards,
Marc Meumann
Steema Support

sring
Newbie
Newbie
Posts: 15
Joined: Thu Jun 30, 2005 4:00 am

Post by sring » Fri Feb 17, 2006 5:53 pm

If I do your first loop, adding in your 3D button 5 times, they all look ok.

When I tried the second loop, the third button comes out black. So, I changed it so that I was inserting my 0 icon 5 times. And, the third one still comes out black, but the other 4 show the 0 icon fine.

sring
Newbie
Newbie
Posts: 15
Joined: Thu Jun 30, 2005 4:00 am

Post by sring » Fri Feb 17, 2006 6:20 pm

This has something to do with setting the ImageIndex.

If, in the second loop, I keep the index at the first button I add, they all look good. If I let the index increment, even if I just do it manually and don't make it depend on the count, and even if I'm adding the same icon 5 times, the third one comes out black.

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Mon Feb 20, 2006 3:25 pm

Hello,

Interesting. That's different to the behaviour in tests here. I wonder if it has anything to do with the programming language.

Is that a useable workaround if you assign a different image to the 'fixed' index? If there's anythiing further we can try please let us know.

Regards,
Marc Meumann
Steema Support

Post Reply