日期:2014-05-18 浏览次数:20907 次
listView_qt.Items.Clear(); SqlConnection conn = BaseClass.DBConn.CyCon(); conn.Open(); SqlCommand cmd = new SqlCommand("select * from T_Ztzl", conn); sdr = cmd.ExecuteReader(); listView_qt.LargeImageList = imageList_qt; imageList_qt.ImageSize = new Size(100, 100); while (sdr.Read()) { string zt = sdr["Ztzt"].ToString().Trim(); string s = sdr["Ztmc"].ToString().Trim(); if (zt.Trim() == "空闲") { Image img = new Bitmap(@"D:\Projects\CYAPP\CYAPP\Image\1.bmp"); Graphics g = Graphics.FromImage(img); SizeF size = g.MeasureString(sdr["Ztmc"].ToString().Trim(), new Font("黑体", 20)); g.DrawString(zt, new Font("黑体", 20), new SolidBrush(Color.White), (img.Width - size.Width) / 2, (img.Height - size.Height) / 2); imageList_qt.Images.Add(img); listView_qt.Items.Add(""); s = null; } else { Image img = new Bitmap(@"D:\Projects\CYAPP\CYAPP\Image\2.bmp"); Graphics g = Graphics.FromImage(img); SizeF size = g.MeasureString(sdr["Ztmc"].ToString().Trim(), new Font("黑体", 20)); g.DrawString(zt, new Font("黑体", 20), new SolidBrush(Color.White), (img.Width - size.Width) / 2, (img.Height - size.Height) / 2); imageList_qt.Images.Add(img); listView_qt.Items.Add(""); s = null; } } listView_qt.Items[0].ImageIndex = 0; sdr.Close(); conn.Close();