将图片添加到列表视图子项[Windows窗体]
我在做用C#Windows窗体项目。
我要显示在列表视图子项的图像。
对于例如: -
存在具有3列的列表视图(列1卷号,列2是StudentName,第3栏是StudentPhoto)。我可以使用ListViewItems在ListView中添加项目。
添加第一项到ListView,
I'm doing project in windows forms using c#. I want to show an image in the listview subitems. For eg:- There is a listview having 3 Columns (Column 1 is Roll number,Column 2 is StudentName,Column 3 is StudentPhoto) .I can use the ListViewItems to add Items in the ListView. Adding First items to the ListView,
ListViewItem item = new ListViewItem("101");
item.SubItem.Add("Robin");
SampleListView.Items.Add(item);
现在我遇到的第3列显示StudentImage困难,谁能帮助!
Now i'm having difficult in Showing StudentImage in the 3rd column,Can anyone help!
请注意:
另外我有ImageList中分配给SampleListView。
Note: Also i have ImageList assigned to SampleListView.
ListView控件并从包的Windows通用控件的本地列表视图控件。这种控制不直接对子项目支持图像。您需要将其设置列表视图业主抽奖,让你处理图形。
ListView does wrap the native list view control from common controls of Windows. This control does not directly support images on subitems. You need to set the listview it to owner draw to let you handle the drawing.
幸运的是别人已经做到了这一点。在$ C $的CProject有一个好之一。
Luckily others have done this already. On CodeProject there is a good one.