如图,数据是从数据库中加载的,选中的项背景变色,默认的ListView实现不了边框,而且选中后背景只突出显示图片和文字,背景颜色还是改变不了。
有什么办法显示每项的边框线,并且选中后整个背景变色,并不是只有文字和图标变色,或者有没有这样的第三方控件?
有什么办法显示每项的边框线,并且选中后整个背景变色,并不是只有文字和图标变色,或者有没有这样的第三方控件?
解决方案 »
- C#实现单点登陆(ADO.net)
- "10-Jul-09"要如何转换成“20090710"
- C#中的ActiveMdiChild事件,如何判断子窗体是关闭还是激活?
- 我想每天下午五点定时从数据库中抓出一些数据生成一份excel文件,大家有没有好的解决方法,谢谢!
- 那位大侠能把这段java代码翻译成c#,很短的一段代码,百分相谢!
- WebService的ip地址不固定,怎么办?
- 请问如何实现WinForm下TreeView用鼠标多选节点,并能实现拖动的方法?
- zhangroc 我已经封杀,您将不能进入.net区(包括c#,asp.net等)
- 谁能提供一些C#关于com编程的书或资源?
- 自画菜单的源代码(OwnerDraw Menu)(第一部分)
- SharpZipLib压缩与解压
- 如何识别数字和运算符?
this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2,
listViewItem3});
this.listView1.LargeImageList = this.imageList1;
this.listView1.Location = new System.Drawing.Point(67, 63);
this.listView1.Name = "listView1";
this.listView1.OwnerDraw = true;
this.listView1.Size = new System.Drawing.Size(282, 264);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(this.listView1_DrawItem); private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
{
Pen p = new Pen(Color.Black);
e.Graphics.DrawRectangle(p, e.Bounds); Rectangle fill = new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 2, e.Bounds.Height - 2);
if (e.Item.Selected)
{
Pen bg = new Pen(Color.AliceBlue);
e.Graphics.FillRectangle(bg.Brush, fill);
} Rectangle rp = new Rectangle(e.Bounds.X + 5, e.Bounds.Y + 5, e.Bounds.Width - 10, e.Bounds.Height - 20);
e.Graphics.DrawImage(this.imageList1.Images[1], rp);
e.Graphics.DrawString(e.Item.Text, this.Font, p.Brush, e.Bounds.X + 5, e.Bounds.Y + e.Bounds.Height - 15); }