this.ls_labname.ImageList = this.imageList1 ; //((System.Drawing.Image)(res.GetObject("ls_labname.Image")));
this.ls_labname .ImageIndex =0;
这两句就够了!

解决方案 »

  1.   

    Sorry,是不是你 .的位置不对啊!
    this.ls_labname.ImageList = this.imageList1; 
    this.ls_labname.ImageIndex =0;
      

  2.   

    我想这段代码里面说的很明白了:
    1. 可以直接在你的窗体form1的label1的属性里面直接的设置一个Image属性,这个属性默认的是从磁盘上面读文件。你可以在ImageAlign里面设置位置的属性。
    2. 另外的一个方法是将图片文件通过ResGen工具转换为*.resources文件;然后将这个文件和你的程序一起编译成一个Assemly。这样的话,你再通过ResourceManager类来读取这个文件再放在ImageList里面,通过你的Label的ImageIndex来访问特定的文件了!
      

  3.   

    Point P = new Point(e.X, e.Y);
    string eventString = null;
    switch (e.Button) 
    {
    case MouseButtons.Left:
    eventString = "L123";
    ToolTip toolTip1 = new ToolTip();
    toolTip1.AutoPopDelay = 5000;
    toolTip1.InitialDelay = 1;
    toolTip1.ReshowDelay = 500;
    toolTip1.ShowAlways = true;
    toolTip1.SetToolTip(this.picMap  ,"X:"+P.X.ToString ()+",Y:"+P.Y.ToString ()); Label ls_labname =new Label();
    ls_labname.Location=new System.Drawing.Point(P.X,16+P.Y);
    ls_labname.Size=new System.Drawing.Size(100, 23);
    ls_labname.Text=eventString;
    ls_labname.ForeColor=System.Drawing.Color.Red;
    ls_labname.Name=eventString;
    ls_labname.ImageList = this.imageList1 ; 
    ls_labname .ImageIndex =0;
    ls_labname.Visible =true;
    this.Controls.Add(ls_labname);
    break;
    不好意思是System.Drawing.Size(100, 23);尺寸太大了.没看见,跑到图片后面了,呵呵
      

  4.   

    beick(水中央) :
    . 另外的一个方法是将图片文件通过ResGen工具转换为*.resources文件;然后将这个文件和你的程序一起编译成一个Assemly。这样的话,你再通过ResourceManager类来读取这个文件再放在ImageList里面,通过你的Label的ImageIndex来访问特定的文件了!对于PictureBox可以用这种方法?如何用?
      

  5.   

    获取或设置 PictureBox 显示的图像。
    [C#]
    public Image Image {get; set;}属性值
    要显示的 Image 对象。备注
    Image 属性被设置为要显示的 Image。该操作可以在设计时或运行时进行。
      

  6.   

    private void Form1_Load(object sender, System.EventArgs e)
    {
         this.myImageList.Images.Add((Image)rm.GetObject("AO"));
         this.pictureBox1.Image = this.myImageList.Images["AO"];
         this.pictureBox1.Refresh();
    }public Form1()
    {  
         // create a resource manager instance.
         rm = new ResourceManager("// 你的Assemly",this.GetType().Assembly);
         InitializeComponent();          
    }