Cassio Posted April 10, 2003 Posted April 10, 2003 Hi! How can I set the Color of a single subitem? I tried listItem.SubItems(1).ForeColor = Color.Red but it has no effect. Thanks. Quote Stream of Consciousness (My blog)
*Experts* Volte Posted April 10, 2003 *Experts* Posted April 10, 2003 Unfortunately, ListView rows must all be the same color; SubItems will take on the color of their parent. Quote
Cassio Posted April 10, 2003 Author Posted April 10, 2003 Ok, thanks. Quote Stream of Consciousness (My blog)
Cassio Posted April 11, 2003 Author Posted April 11, 2003 Is there a way to insert a picture in a listview? Thanks! Quote Stream of Consciousness (My blog)
iebidan Posted April 11, 2003 Posted April 11, 2003 Well actually you can have multiple items in a listview each one with different colors, first you need to declare a variable that will contain the Color class Dim Clr as System.Drawing.Color After that start filling your Listview with your items and subitems, but after setting the first column you need to set the color ListView1.Items.Add("Item One") ListView1.Items.Item(i).ForeColor = Clr.Red ListView1.Items(i).SubItems.Add("SubItem One") All subitems will take the color, the example should look something like this Private Sub Button1_Click (ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i as Integer Dim Clr as System.Drawing.Color For i=0 to 100 ListView1.Items.Add("Item " & i) ListView1.Items.Item(i).ForeColor = Clr.Red ListView1.Items(i).SubItems.Add("SubItem " & i) Next End Sub You can change the color for each item in the listview, try it out, and let me know if you have any problems Regards Quote Fat kids are harder to kidnap
*Gurus* divil Posted April 11, 2003 *Gurus* Posted April 11, 2003 I think he wanted to change the colours of each SUBitem individually... Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
donaldc104 Posted April 14, 2003 Posted April 14, 2003 SOLUTION: I change the color of individual cells in a List View control. I highlight cells in pink to show errors. lvwStats.Items(iIndex).SubItems(3).BackColor = Color.LightPink Normally my ListView is all white, with scattered cells highlighted in pink. Quote
donaldc104 Posted April 15, 2003 Posted April 15, 2003 You have to set up for column independence at item-add time. Example: itemNew.SubItems.Add("item1") itemNew.SubItems.Add("item2") itemNew.UseItemStyleForSubItems = False ' Cell independence... lvwTest.Items.AddRange(New ListViewItem() {itemNew}) Hey, I finally stumped the moderators on one! Do I get a badge or something? . Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.