在程序中要用到一些图片,具体该怎么做呢?

解决方案 »

  1.   

    什么程序,web还是form,用来干什么,这个问题实在是不懂
      

  2.   

    form中,像把一些图片放到datagridview中的行标头,根据内容的不同来显示不同的图标,比如内容是“warning”的就显示感叹号
      

  3.   

    imagelist中加入你的图片,然后在你要使用图片的控件中将属性设置到当前的imagelist,选择一个index就可以了
      

  4.   


    //程序上下文...Graphics grfx = CreateGraphics();
    Image image = image.FromFile("路径");
    grfx.DrawImage(image,0,0);//程序上下文
      

  5.   

    可是,我看到人家这样用的  /// <summary>
            ///   返回此类使用的缓存 ResourceManager 实例。
            /// </summary>
            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
            internal static global::System.Resources.ResourceManager ResourceManager {
                get {
                    if (object.ReferenceEquals(resourceMan, null)) {
                        global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestDataGridViewRowStyle.Properties.Resources", typeof(Resources).Assembly);
                        resourceMan = temp;
                    }
                    return resourceMan;
                }
            }
            
            /// <summary>
            ///   为使用此强类型资源类的所有资源查找
            ///   重写当前线程的 CurrentUICulture 属性。
            /// </summary>
            [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
            internal static global::System.Globalization.CultureInfo Culture {
                get {
                    return resourceCulture;
                }
                set {
                    resourceCulture = value;
                }
            }
            
            internal static System.Drawing.Bitmap arrow {
                get {
                    object obj = ResourceManager.GetObject("arrow", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap down {
                get {
                    object obj = ResourceManager.GetObject("down", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap GradeA {
                get {
                    object obj = ResourceManager.GetObject("GradeA", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap GradeB {
                get {
                    object obj = ResourceManager.GetObject("GradeB", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap GradeC {
                get {
                    object obj = ResourceManager.GetObject("GradeC", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap GradeD {
                get {
                    object obj = ResourceManager.GetObject("GradeD", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap GradeF {
                get {
                    object obj = ResourceManager.GetObject("GradeF", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap high {
                get {
                    object obj = ResourceManager.GetObject("high", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap low {
                get {
                    object obj = ResourceManager.GetObject("low", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }
            
            internal static System.Drawing.Bitmap up {
                get {
                    object obj = ResourceManager.GetObject("up", resourceCulture);
                    return ((System.Drawing.Bitmap)(obj));
                }
            }这里面的internal static System.Drawing.Bitmap arrow 之类的东西是自己手动添加的吗?还是自动生成的?
      

  6.   

    System.Drawing.Bitmap是GDI+封装的类
    用到需要自己添加 不是自动生成的
      

  7.   

    为什么我把上面的代码添加进去后,提示
    “类型“remoting.Properties.Resources”已经包含“ResourceManager”的定义”?
    “类型“remoting.Properties.Resources”已经包含“Culture”的定义”?
      

  8.   

    Rectangle _Col= dataGridView1.GetCellDisplayRectangle(0, 0, true);
    e.Graphics.DrawIcon(this.Icon, new Rectangle(0, _Col.Y, _Col.X, _Col.Height)); 

    第一列用Image控件,设置图片

    private void DataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
        if (DataGridView1.Columns[e.ColumnIndex].Name.Equals("Image"))
        {
            string path = e.Value.ToString();
            e.Value = GetImage(path);
        }

    public System.Drawing.Image GetImage(string path)
    {
        return System.Drawing.Image.FromFile(path);