绘制图像到一个子项在ListView [英] Drawing an Image to a subItem in the ListView

查看:103
本文介绍了绘制图像到一个子项在ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的列表视图是建立在细节与下列标题查看:

My Listview is setup in the details view with the following column headers:

映像名称||图像位置||图像大小||图片preVIEW

Image Name || Image Location || Image Size || Image Preview

我想知道是否有在第4列有绘制图像的方法。我所知道的唯一办法,就是设置

I would like to know if there is a way to draw an image in the 4th column there. The only way I know, is to set

this.listview1.OwnerDraw = true
this.listView1.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(listView1_DrawColumnHeader);
this.listView1.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(listView1_DrawItem);
this.listView1.DrawSubItem += new System.Windows.Forms.DrawListViewSubItemEventHandler(listView1_DrawSubItem);

这个问题是我必须处理所有列表视图绘制自己...
我不知道是否有更好的方法图像绘制到一个子项,或者如果有一种方法可以只处理DrawSubItem事件?

The problem with this is I have to handle ALL the listview drawing myself... I was wondering if there is a better way to draw in image to a subItem, or if there is a way to only handle the DrawSubItem event?

推荐答案

listView1_DrawColumnHeader listView1_DrawItem 事件处理程序你应该把这个

In listView1_DrawColumnHeader and listView1_DrawItem event handlers you should put this

e.DrawDefault = true;

它将用于列和项目缺省的绘图实现,你所要做的就是写自己的实现只为子项。

It will use default drawing implementation for columns and items, all you have to do is write your own implementation only for subitems.

这篇关于绘制图像到一个子项在ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆