开发者

How to get callbacks for a ListView sub-item? (Partial Owner-draw)

I have a ListView that contains items with four columns. The values in three of the columns are pretty much fixed (although editable via an item editing dialog), but the value in the fourth is an index, and I want it to be calculated on the fly.

I know that I could use an owner-draw list, but, unless I don't get the examples in MSDN, it looks like I have to take responsibility for all the painting and rendering of items in the other three columns. All I need is for the control to ask me what the text for the index for each item before it draws it.

Is this possible? Any known work开发者_StackOverflow社区arounds if not?


You can use owner draw but still get the ListView to draw some of the subitems itself by setting ev.DrawDefault to true for those columns:

private void MyList_DrawSubItem(object sender, DrawListViewSubItemEventArgs ev)
{
    if (!this_is_an_interesting_column(ev.ColumnIndex))
    {
        ev.DrawDefault = true;
        return;
    }

    now_handle_the_interesting_column();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜