先上图:
来源:互联网 发布:汉语编程语言 编辑:程序博客网 时间:2024/04/28 08:46
先上图:
这里添加固定的图片的。
代码:
- private Color RowBackColorAlt=Color.FromArgb(200,200,200);//交替色
- private Color RowBackColorSel = Color.FromArgb(150, 200, 250);//选择项目颜色
- public Form1()
- {
- InitializeComponent();
- listBox1.DrawMode = DrawMode.OwnerDrawFixed;
- listBox1.ItemHeight = 24;
- }
- private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
- {
- Brush myBrush = Brushes.Black;
- if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
- {
- myBrush = new SolidBrush(RowBackColorSel);
- }
- else if (e.Index % 2 == 0)
- {
- myBrush = new SolidBrush(RowBackColorAlt);
- }
- else
- {
- myBrush = new SolidBrush(Color.White);
- }
- e.Graphics.FillRectangle(myBrush, e.Bounds);
- e.DrawFocusRectangle();//焦点框
- //绘制图标
- Image image = Image.FromFile("images/item.png");
- Graphics g = e.Graphics;
- Rectangle bounds = e.Bounds;
- Rectangle imageRect = new Rectangle(
- bounds.X,
- bounds.Y,
- bounds.Height,
- bounds.Height);
- Rectangle textRect = new Rectangle(
- imageRect.Right,
- bounds.Y,
- bounds.Width - imageRect.Right,
- bounds.Height);
- if (image != null)
- {
- g.DrawImage(
- image,
- imageRect,
- 0,
- 0,
- image.Width,
- image.Height,
- GraphicsUnit.Pixel);
- }
- //文本
- StringFormat strFormat = new StringFormat();
- //strFormat.Alignment = StringAlignment.Center;
- strFormat.LineAlignment = StringAlignment.Center;
- e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), textRect,strFormat);
- }
- 先上图:
- 传上图试试
- 上图"机器翻译"相关书目
- 上图:药学笔记系列
- 上图turbo c书目
- 上图:turbo prolog
- 上图借书录
- 网页上图片跳动
- 获取网络上图片
- OpenLayers4文本上图实例
- 爱拼宝宝的界面还是很全面的。标准的电商首页,而且内容也很丰富,详情,参团评论等。 要下载的同学下载链接在最底部,先上图片和部分代码示例:
- 非健康的体育课上图看了上图看
- 互联网上图像信息检索
- 上图"自然语言处理"相关书目
- 网页上图片禁止下载
- 上图波利亚所著图书
- 互联网上图像信息检索
- 笔筒完成了一部分,上图
- Session和Cookie知识点注意事项
- C#将汉字字符换转换为阿拉伯数字
- Redis资料汇总专题
- [HTML5]配置Ngnix服务器支持manifest
- 属性/方法名: 说明:
- 先上图:
- 用java构建企业级自动化框架(第四篇-构建框架分布式并发执行测试用例功能2)
- 当Google忙着忽悠Android的时候,各位别忘了还有Html5!
- oracle查询语句优化
- ContentObserver类详解
- 高负载应用下的mysql数据库彻底优化
- 不再迷惘,执着于我的方向(写的挺好转一下)
- C# WinCE下播放*.wav,*.mp3 详解(适用WinCE6.0和以前的所有版本)
- 在虚拟机LINUX操作系统中修改文件内容