0

I have really weird problem. In my simple project in c#/winforms I had ToolStrip with inserted standard buttons. It was all ok but suddenly after one restart icons just disappeared. Buttons were still there but with no image.

I was pretty shocked by this and couldn't find any bug. Well, I added another ToolStrip with standard buttons. Icons were there. I noticed, that in Designer.cs file new buttons definitions had line:

this.newToolStripButton1.Image = 
      ((System.Drawing.Image)(resources.GetObject("newToolStripButton1.Image")));

Unfortunately after restart those lines just disappears aswell as the icons.

What could be the problem? How to solve it?

Kapil Khandelwal
  • 15,958
  • 2
  • 45
  • 52
Joe
  • 2,551
  • 6
  • 38
  • 60
  • Maybe a corrupted resource file? You could try recreating the resx file. – kor_ Dec 18 '12 at 12:20
  • Your suggestion didn't solve the problem. I don't know actually what was the problem. I have solved it by adding new ToolStrip then just save all icons from the resx file to a folder and then bind those images to my original ToolStrip buttons. Thx – Joe Dec 18 '12 at 14:26

1 Answers1

0

Just had a similar problem where my ToolStripButtons dis-attached themselves form the ToolStrip. I was going along nicely, compiled and ran my program and the ToolStripButtons simply went AWOL.

Doing a web search, this seems to happen occasionally without any real answer as to why.

Looking in the designer file, the 'this.myToolStrip.Items.AddRange' command had disappeared from myToolStrip section of the form, but the buttons where still there.

To fix, I simply added it back (in the Designer file)...

this.myToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.myToolStripButton1,
this.myToolStripButton2,
this.myToolStripButton3,
this.myToolStripButton4});

To get the format, just add a new button to the existing ToolStrip and search the designer for 'AddRange'.

damichab
  • 162
  • 10