-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathListViewEx.cs
46 lines (40 loc) · 1.25 KB
/
ListViewEx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace KCB2
{
public class ListViewEx : ListView
{
public ListViewEx()
{
OwnerDraw = true;
DoubleBuffered = true;
DrawSubItem += this_DrawSubItem;
DrawColumnHeader += this_DrawColumnHeader;
}
void this_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
//これがないと描画されない。
e.DrawDefault = true;
}
void this_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.SubItem is IOwnerDrawLVSubItem)
//描画をカスタマイズするサブアイテムの場合は描画を呼ぶ
((IOwnerDrawLVSubItem)e.SubItem).DrawSubItem(e);
else
//そうでなければシステムに描画を任せる
e.DrawDefault = true;
}
}
public interface IOwnerDrawLVSubItem
{
/// <summary>
/// サブアイテム描画ハンドラ
/// </summary>
/// <param name="e"></param>
void DrawSubItem(DrawListViewSubItemEventArgs e);
}
}