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. Windows Forms
  4. Highlight text only in a listview subitem

Highlight text only in a listview subitem

Scheduled Pinned Locked Moved Windows Forms
tutorialcsharpquestion
6 Posts 3 Posters 24 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.
  • I Offline
    I Offline
    iWonderHow
    wrote on last edited by
    #1

    Hi There, I'm about to make a small application Windows Form/C# to keep different kind of informations such as passwords credit card info etc. It is rather simple with a treeview on the left side and a listview on the right side. Now I implement 'Search' and 'Find next' and it works fine so far in both views. However when I find and highlight a hit in a listview subitem the entire cell (background) is highlighted but I only want to highlight the text itself. (I would like to add some screen shots but I don't know how to do it). Any ideas how to solve this (code example are very much appreciated)? Thanks in advance,

    L B 2 Replies Last reply
    0
    • I iWonderHow

      Hi There, I'm about to make a small application Windows Form/C# to keep different kind of informations such as passwords credit card info etc. It is rather simple with a treeview on the left side and a listview on the right side. Now I implement 'Search' and 'Find next' and it works fine so far in both views. However when I find and highlight a hit in a listview subitem the entire cell (background) is highlighted but I only want to highlight the text itself. (I would like to add some screen shots but I don't know how to do it). Any ideas how to solve this (code example are very much appreciated)? Thanks in advance,

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      iWonderHow wrote:

      Any ideas how to solve this

      You'll have to draw it yourself.

      iWonderHow wrote:

      code example are very much appreciated

      Available on MSDN[^].

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

      I 1 Reply Last reply
      0
      • L Lost User

        iWonderHow wrote:

        Any ideas how to solve this

        You'll have to draw it yourself.

        iWonderHow wrote:

        code example are very much appreciated

        Available on MSDN[^].

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

        I Offline
        I Offline
        iWonderHow
        wrote on last edited by
        #3

        Hi Eddy, Thanks for your reply. I already had a look at that link and https://msdn.microsoft.com/en-us/library/system.windows.forms.listview.drawsubitem(v=vs.110).aspx[^] as well. However that example as well as others draws the entire cell in the same color. My problem is that I'm not a very skilled C#/.NET programmer, but I'll try to dig deeper into that subject. When/if I find a solution I'll post it here.

        1 Reply Last reply
        0
        • I iWonderHow

          Hi There, I'm about to make a small application Windows Form/C# to keep different kind of informations such as passwords credit card info etc. It is rather simple with a treeview on the left side and a listview on the right side. Now I implement 'Search' and 'Find next' and it works fine so far in both views. However when I find and highlight a hit in a listview subitem the entire cell (background) is highlighted but I only want to highlight the text itself. (I would like to add some screen shots but I don't know how to do it). Any ideas how to solve this (code example are very much appreciated)? Thanks in advance,

          B Offline
          B Offline
          Brisingr Aerowing
          wrote on last edited by
          #4

          Take a look here[^] This control can do all that... And a whole lot more! You will have to completely redo anything already using a list view, though, but the added power and flexibility is well worth it. Just take note of the license being GPLv3. I have used this control before, and it is AWESOME!

          What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

          I 1 Reply Last reply
          0
          • B Brisingr Aerowing

            Take a look here[^] This control can do all that... And a whole lot more! You will have to completely redo anything already using a list view, though, but the added power and flexibility is well worth it. Just take note of the license being GPLv3. I have used this control before, and it is AWESOME!

            What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

            I Offline
            I Offline
            iWonderHow
            wrote on last edited by
            #5

            Hi Brisingr, Thanks for your reply. I have already had a look at ObjectListView but I discarded it because it also carries a lot of code that I do not need - I hoped for something more simple. But you may be right that it is no other alternatives to do a lot of hard coding myself. Anyway I will once again consider to use it. Thanks :) ,

            B 1 Reply Last reply
            0
            • I iWonderHow

              Hi Brisingr, Thanks for your reply. I have already had a look at ObjectListView but I discarded it because it also carries a lot of code that I do not need - I hoped for something more simple. But you may be right that it is no other alternatives to do a lot of hard coding myself. Anyway I will once again consider to use it. Thanks :) ,

              B Offline
              B Offline
              Brisingr Aerowing
              wrote on last edited by
              #6

              Yeah, it is a rather heavy control. But I cut out about 65% of the code in the application I was using it for, so that is a big win. (Yes, 65% of the code was for handling list view related operations, and I was only about 30% done with the program!)

              What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

              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