using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
using System.Resources;
using System.Reflection;namespace 连连看
{
    public partial class Form1 : Form
    {  
        
        Image[] PicImg = new Image[39];
        public Form1()
        {
            InitializeComponent();
            GetImg();
        }
        
        public void GetImg()
        {
            Graphics g = this.CreateGraphics();
            g.DrawLine(new Pen(new SolidBrush(Color.DeepSkyBlue), 5), 0, 11 * 34 + 5, 19 * 34, 11 * 34 + 5);
            
            for (int i = 0; i < 39; i++)
            {
                ResourceManager rm = new ResourceManager("连连看.PicResource", Assembly.GetExecutingAssembly());
                PicImg[i] = (Image)rm.GetObject(i.ToString());
            }
            g.DrawImage(newImage, new Point(100, 300));
        }
    }
}
如上代码 图片资源存在  却没有在Point(100, 100) 显示出来 为什么??

解决方案 »

  1.   

    1:你说的图片资源存在是什么意思?
    我想你需要做如下的检查:
    *:rm对象是否为空?
    *:在你赋值给PicImg[i],请检查rm.GetObject(i.ToString())返回的结果是否为null?
    2:我不记得对resourceManager中资源名称引用的格式了,如果你的名称不正确,可能导致rm返回的值为null,我查查再回复下。
      

  2.   

            private void Form1_Paint( object sender, PaintEventArgs e )
            {
                GetImg(); 
            } 
    执行顺序的问题啊。
      

  3.   

    g.DrawImage(newImage, new Point(100, 300)); 
    这个变量你是如何定义/赋值的?