• 0

[C#] Change color of items in CheckedListBox


Question

9 answers to this question

Recommended Posts

  • 0

To do this, your item must be a htmlcontrols.htmlselect NOT a webcontrols.CheckListbox

Like <select id="ddlListBox" runat="server">

this.ddlListBox.Items[this.ddlListBox.SelectedIndex].attributes.add("style","background-colour:red

or

this.ddlListBox.Items[this.ddlListBox.SelectedIndex].attributes.add("class","RedBox

  • 0
  robotnic said:
lunamonkey, you are first indeed, but this does not help me, since i'm using WindowsForms and not WebForms

585946681[/snapback]

Sorry dude, got carried away with web stuff.

Might not be possible with windows forms... there's no attributes or anything.

post-29476-1116598882.gif

  • 0

I think lunamonkey is right here. Usualy, in Rich Edit boxes and similer controls, you can select certain parts of the text and change their attributes. Ive been messing around with the control a few mins, and couldnt find anything changeable in a single item class.

  • 0

Can you use a ListView control with the CheckBoxes property set to true and View property to List, instead of using the CheckedListBox control?

In that case, there should be a pretty "clean" method, like this:

ListViewItem lvItem = new ListViewItem("Bla bla");
lvItem.ForeColor = Color.Yellow;
lvItem.BackColor = Color.Black;
listView.Items.Add(lvItem);

Otherwise, yeah, overriding controls, and essentially making a custom control, is flexible and should be able to do this among other things.

  • 0
  Jugalator said:
Can you use a ListView control with the CheckBoxes property set to true and View property to List, instead of using the CheckedListBox control?

In that case, there should be a pretty "clean" method, like this:

ListViewItem lvItem = new ListViewItem("Bla bla");
lvItem.ForeColor = Color.Yellow;
lvItem.BackColor = Color.Black;
listView.Items.Add(lvItem);

Otherwise, yeah, overriding controls, and essentially making a custom control, is flexible and should be able to do this among other things.

585946811[/snapback]

Thanks :)

I tried to use ListBox with my own DrawItem..

But with list view it looks much better, and the checkboxes are themed!

thanks

:)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.