ListViewItem.SubItems.BackColor ???
-
Hi guys, is it anyhow possible to change the backcolor of a specific subitem in a listview? Or is it only possible to change the color of the whole item with
ListViewItem.BackColor
? Likely it won't work without deriving from ListView... :sigh: Regards, mYkel -
Hi guys, is it anyhow possible to change the backcolor of a specific subitem in a listview? Or is it only possible to change the color of the whole item with
ListViewItem.BackColor
? Likely it won't work without deriving from ListView... :sigh: Regards, mYkelThis Codeproject article, http://www.codeproject.com/listctrl/selectentirerow.asp?target=LVS%5FOWNERDRAWFIXED[^], shows some of what you need, but it's in C++/MFC, not C#! Basically you need to add the
LVS_OWNERDRAWFIXED
style to your derived ListView, and handle the[WM_DRAWITEM](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/comboboxes/comboboxreference/comboboxmessages/wm_drawitem.asp)
windows message and the corresponding DRAWITEMSTRUCT, which contains theiItemID
of the item to draw. You can add the style to by overriding the ListView'sCreateParams
property and intercept theWM_DRAWITEM
in your overridenDefWndProc
. The MSDN says this aboutLVS_OWNERDRAWFIXED
: "The owner window can paint items in report view. The list-view control sends a WM_DRAWITEM message to paint each item; it does not send separate messages for each subitem. The iItemData member of the DRAWITEMSTRUCT structure contains the item data for the specified list-view item. "Ian Mariano - http://www.ian-space.com/
"We are all wave equations in the information matrix of the universe" - me