Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ListViewItem.SubItems.BackColor ???

ListViewItem.SubItems.BackColor ???

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sps itsec46
    wrote on last edited by
    #1

    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

    I 1 Reply Last reply
    0
    • S sps itsec46

      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

      I Offline
      I Offline
      ian mariano
      wrote on last edited by
      #2

      This 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 the iItemID of the item to draw. You can add the style to by overriding the ListView's CreateParams property and intercept the WM_DRAWITEM in your overriden DefWndProc. The MSDN says this about LVS_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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups