日期:2014-05-19  浏览次数:20715 次

图像显示不出来
private   void   gdipic_Load(object   sender,   System.EventArgs   e)
{
ListPicture();
}

void   ListPicture()
{
Bitmap   bm=new   Bitmap(@ "F:\下载\myWindowsForm\WindowsForm\WindowsForm\bin\Debug\images\out2188_L.jpg ");

Graphics   g=this.CreateGraphics();

g.DrawImage(bm,1,1);
}

环境是.net   1.1     图片在页面上显示不出来

------解决方案--------------------
// Create image.
Image newImage = Image.FromFile( "SampImag.jpg ");

// Create coordinates for upper-left corner of image.
int x = 100;
int y = 100;

// Draw image to screen.
e.Graphics.DrawImage(newImage, x, y);

------解决方案--------------------
在Paint事件里调用ListPicture函数就可以了.


因为在Load事件里窗体还未显示,等它显示出来时又会被默认的Paint事件所重绘掉了.