this.ls_labname.ImageList = this.imageList1 ; //((System.Drawing.Image)(res.GetObject("ls_labname.Image")));
this.ls_labname .ImageIndex =0;
这两句就够了!
this.ls_labname .ImageIndex =0;
这两句就够了!
解决方案 »
- 查询数据到dataGridView,再以dataGridView里的数据做条件,批量对比另一个表数据!
- listview的问题
- asp.net 3.5 (C#) + Vs2008 请教附件下载代码
- winform问题,晕,搞了那么久
- 关于把字符串转换ShortCut的问题?
- 用C#如何将xml文件中的所有节点都保存到一个XmlNodeList中,求代码
- this.listView2 = this.listView1; 是传值还是传引用?
- 各位高手,帮我看看什么问题?
- (急!!)小弟初来乍到,这有一个问题还请各前辈请教:如何用程序控制在SQL SERVER2000中添加用户
- 如何读取这个Xml文档呢请教各位
- 提示asp.net版本不对问题 在线等啊!
- 帮帮忙,我已经连接TCP/IP连接了服务器?但不知道怎么接收数据啊
this.ls_labname.ImageList = this.imageList1;
this.ls_labname.ImageIndex =0;
1. 可以直接在你的窗体form1的label1的属性里面直接的设置一个Image属性,这个属性默认的是从磁盘上面读文件。你可以在ImageAlign里面设置位置的属性。
2. 另外的一个方法是将图片文件通过ResGen工具转换为*.resources文件;然后将这个文件和你的程序一起编译成一个Assemly。这样的话,你再通过ResourceManager类来读取这个文件再放在ImageList里面,通过你的Label的ImageIndex来访问特定的文件了!
string eventString = null;
switch (e.Button)
{
case MouseButtons.Left:
eventString = "L123";
ToolTip toolTip1 = new ToolTip();
toolTip1.AutoPopDelay = 5000;
toolTip1.InitialDelay = 1;
toolTip1.ReshowDelay = 500;
toolTip1.ShowAlways = true;
toolTip1.SetToolTip(this.picMap ,"X:"+P.X.ToString ()+",Y:"+P.Y.ToString ()); Label ls_labname =new Label();
ls_labname.Location=new System.Drawing.Point(P.X,16+P.Y);
ls_labname.Size=new System.Drawing.Size(100, 23);
ls_labname.Text=eventString;
ls_labname.ForeColor=System.Drawing.Color.Red;
ls_labname.Name=eventString;
ls_labname.ImageList = this.imageList1 ;
ls_labname .ImageIndex =0;
ls_labname.Visible =true;
this.Controls.Add(ls_labname);
break;
不好意思是System.Drawing.Size(100, 23);尺寸太大了.没看见,跑到图片后面了,呵呵
. 另外的一个方法是将图片文件通过ResGen工具转换为*.resources文件;然后将这个文件和你的程序一起编译成一个Assemly。这样的话,你再通过ResourceManager类来读取这个文件再放在ImageList里面,通过你的Label的ImageIndex来访问特定的文件了!对于PictureBox可以用这种方法?如何用?
[C#]
public Image Image {get; set;}属性值
要显示的 Image 对象。备注
Image 属性被设置为要显示的 Image。该操作可以在设计时或运行时进行。
{
this.myImageList.Images.Add((Image)rm.GetObject("AO"));
this.pictureBox1.Image = this.myImageList.Images["AO"];
this.pictureBox1.Refresh();
}public Form1()
{
// create a resource manager instance.
rm = new ResourceManager("// 你的Assemly",this.GetType().Assembly);
InitializeComponent();
}