Listview item and color

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick De Ridder

    Listview item and color

    In a list view with various columns with numbers, I would like to give
    a few numbers a different color. I would be happy to know how can it
    be done.

    Many thanks.
    --
    Regards,
    Patrick.
  • timtos

    #2
    Re: Listview item and color

    You can use the ListViewItem.Li stViewSubItem Properties:

    ListView listView;
    ListViewItem item = new ListViewItem("T est");
    item.UseItemSty leForSubItems = false;
    item.SubItems.A dd("Text", cForeColor, cBackColor, fFont);
    ....

    Or have a look here:


    Hope this helps.
    Greetings,
    timtos.

    "Patrick De Ridder" <patrick.de.rid der@hetnet.nl> wrote in message news:22tbmv8t8r kf2fbvclkegu753 2aaqsvti3@4ax.c om...[color=blue]
    > In a list view with various columns with numbers, I would like to give
    > a few numbers a different color. I would be happy to know how can it
    > be done.
    >
    > Many thanks.
    > --
    > Regards,
    > Patrick.[/color]


    Comment

    • Patrick De Ridder

      #3
      Re: Listview item and color

      On Mon, 15 Sep 2003 19:32:05 +0200, "timtos" <tirobu@gmx.d e> wrote:
      [color=blue]
      >You can use the ListViewItem.Li stViewSubItem Properties:
      >
      >ListView listView;
      >ListViewItem item = new ListViewItem("T est");
      >item.UseItemSt yleForSubItems = false;
      >item.SubItems. Add("Text", cForeColor, cBackColor, fFont);
      >...
      >
      >Or have a look here:
      >http://www.codeproject.com/cs/miscctrl/aa_listview.asp
      >
      >[/color]
      I think I followed a different approach. Like so

      ListViewItem list = new ListViewItem (show)
      ListView1.Items .Add(list)

      I have this code in a loop. During each iteration
      I fill the show array with new values.

      Now in some cases I would like to colour items
      and would like to know how to do this in line
      with the above coding.

      (I did find your article very interesting though.)

      --
      Regards,
      Patrick.

      Comment

      • timtos

        #4
        Re: Listview item and color

        Perhaps I don´t understand you...

        Do you want something like this:

        0 1 2 3
        ----------|----------|----------|----------|
        Text1 Black Green Blue
        Text2 Black Green Blue
        Text3 Black Green Blue
        Text4 Black Green Blue

        If this is not what you want you have to explain it once again ;-)
        Greetings, timtos.

        "Patrick De Ridder" <patrick.de.rid der@hetnet.nl> wrote in message news:3jacmvgafl 3qr0fss48kte68i c4ghrgevf@4ax.c om...[color=blue]
        > On Mon, 15 Sep 2003 19:32:05 +0200, "timtos" <tirobu@gmx.d e> wrote:
        >[color=green]
        > >You can use the ListViewItem.Li stViewSubItem Properties:
        > >
        > >ListView listView;
        > >ListViewItem item = new ListViewItem("T est");
        > >item.UseItemSt yleForSubItems = false;
        > >item.SubItems. Add("Text", cForeColor, cBackColor, fFont);
        > >...
        > >
        > >Or have a look here:
        > >http://www.codeproject.com/cs/miscctrl/aa_listview.asp
        > >
        > >[/color]
        > I think I followed a different approach. Like so
        >
        > ListViewItem list = new ListViewItem (show)
        > ListView1.Items .Add(list)
        >
        > I have this code in a loop. During each iteration
        > I fill the show array with new values.
        >
        > Now in some cases I would like to colour items
        > and would like to know how to do this in line
        > with the above coding.
        >
        > (I did find your article very interesting though.)
        >
        > --
        > Regards,
        > Patrick.[/color]


        Comment

        • Patrick De Ridder

          #5
          Re: Listview item and color

          On Tue, 16 Sep 2003 00:31:12 +0200, "timtos" <tirobu@gmx.d e> wrote:
          [color=blue]
          >Perhaps I don´t understand you...
          >[/color]


          More something like this
          [color=blue]
          >
          > 0 1 2 3
          >----------|----------|----------|----------|
          >bla bla bla bla
          >bla bla bla redbla
          >bla bla bla redbla
          >bla bla bla bla
          >[/color]

          Nice of you to respond again.
          Chao.
          --
          Regards,
          Patrick.

          Comment

          • timtos

            #6
            Re: Listview item and color

            If you want something like this you omit some information.
            How do you add the subitems? In the loop you showed me,
            only the main items were added. And what exactly is "show"?

            If you like to you can send me a minimized test application, so
            that I can have a look at the code myself.

            Sorry for not being able to help at the moment,
            timtos.

            "Patrick De Ridder" <patrick.de.rid der@hetnet.nl> wrote in message news:f2gcmv8kms 5scr7963tbnacgh barhvlnhj@4ax.c om...[color=blue]
            > On Tue, 16 Sep 2003 00:31:12 +0200, "timtos" <tirobu@gmx.d e> wrote:
            >[color=green]
            > >Perhaps I don´t understand you...
            > >[/color]
            >
            >
            > More something like this
            >[color=green]
            > >
            > > 0 1 2 3
            > >----------|----------|----------|----------|
            > >bla bla bla bla
            > >bla bla bla redbla
            > >bla bla bla redbla
            > >bla bla bla bla
            > >[/color]
            >
            > Nice of you to respond again.
            > Chao.
            > --
            > Regards,
            > Patrick.[/color]


            Comment

            • Patrick De Ridder

              #7
              Re: Listview item and color

              On Tue, 16 Sep 2003 12:54:16 +0200, "timtos" <tirobu@gmx.d e> wrote:
              [color=blue]
              >If you like to you can send me a minimized test application, so
              >that I can have a look at the code myself.[/color]
              *************** **
              I will send you a minimized example this evening (16/09).
              --
              Regards,
              Patrick.

              Comment

              Working...