首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

图像展示不出来

2011-12-11 
图像显示不出来privatevoidgdipic_Load(objectsender,System.EventArgse){ListPicture()}voidListPicture

图像显示不出来
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事件所重绘掉了.

热点排行