在设计器中创建的ImageList - 哪里是code? [英] ImageList created in Designer - Where is the code?

查看:106
本文介绍了在设计器中创建的ImageList - 哪里是code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前段时间我用Designer创建一个的ImageList 的ListView 。现在我正在寻找这些图像和code控制的ImageList ,但无法找到它。 查找所有引用不显示所有的(我认为这将是在的InitializeComponent )。

A while ago I used the Designer to create an ImageList for a ListView. Now I'm looking for those images and the code controlling the ImageList but can't find it. "Find all References" doesn't show all of it (I thought it would be in InitializeComponent).

我可以使用设计器来设置 IMAGESIZE ,却找不到,在code的任何地方。不仅如此 - 但如果我以后调用的InitializeComponent 手动添加 - 图像在运行时消失。

I can use the Designer to set the ImageSize, but can't find that anywhere in the code. Not only that - but if I add it manually after the call to InitializeComponent - the images disappear at runtime.

我找不到任何地方的解决方案资源管理器中的图像无论是。

I can't find the images anywhere in Solution Explorer either.

需要明确的是 - 在图像的执行的节目在运行时

To be clear - the images do show at runtime.

推荐答案

当您添加资源的一种形式(的ImageList ,表格图标等),它将被保存在形式的资源(RESX文件)。

When you add resource to a form (ImageList, form Icon, etc), it will be saved in the form resources (resx-file).

他们在的InitializeComponent()的方法,这就是所谓的形式构造函数中自动加载。

They are automatically loaded in InitializeComponent() method, which is called in the form constructor.

private void InitializeComponent()
{
    System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
    ...
    this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
    ...
    this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
    ...
 }

这篇关于在设计器中创建的ImageList - 哪里是code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆