读书人

图像展示不出来

发布时间: 2011-12-11 23:19:43 作者: rapoo

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

读书人网 >C#

热点推荐