我正在处理一个较旧的项目,并将其更新。该程序的一部分有一个带有许多按钮的工具栏,每个按钮都带有一个图像。我发现,图像被存储在用于RESX形式的Base64编码的ImageStream并且这样获得:在资源中添加图像到Base64编码ImageStream(resx)
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
...
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
...
this.toolStrip1.ImageList = this.imageList1;
...
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
...
this.toolStripButton1.ImageIndex = 0; //There are 41 images, so this can be between 0 and 40
我需要用新的图像添加其他按钮。如何将图像添加到此流?
我不能使用设计器,因为它一旦我加载表单(我相信因为它使用不安全的代码自定义组件),它崩溃。
我总是可以添加一个独立于流的新图像资源,但这会使该按钮不同,因此会产生一致性问题,从而导致维护问题。所以我想知道是否有我编辑图像流。我可以访问原始的base64字符串,但我不知道该从哪里去。
我试过了,但VS2008现在将toolstripbutton图像作为单独的资源图像存储。 – NickAldwin 2010-06-14 16:54:06
(而不是作为一个图像流资源) – NickAldwin 2010-06-14 17:14:18
尝试将ImageList复制到新窗体,然后添加图像 – AMissico 2010-06-14 17:20:57