Re: Excel: Display combobox as listview subitem Thanks for replying, Kyle123. There will be two listviews in report view, 1 with 3 columns, the other with 10-ish. Jun 03, 2008 Hi Guys, Hope someone can help me on this question it's two part but here's the background -- I have a ListView and 5 text boxes with a Add Button.
In the loop that goes through each item and adds it, you can use code like this to change colors of items that meet the criteria: If CDec(lvi.SubItems(1).Text) CDec(lvi.SubItems(6).Text) Then lvi.UseItemStyleForSubItems = False lvi.SubItems(1).ForeColor = Color.Blue End If This code assumes that there will be a numeric value in all cells in those two columns. You could alternatively run the code independently after the list view is populated: For Each lvi As ListViewItem In ListView1.Items If CDec(lvi.SubItems(1).Text) CDec(lvi.SubItems(2).Text) Then lvi.UseItemStyleForSubItems = False lvi.SubItems(1).ForeColor = Color.Red End If Next Hope this helps. Thanks Ged, Three years later this code was helpful to me.! Although I may not have worked it out in the best coding fashion.
I still got my code to work. I have a listview with 8 columns (0 - 8) and I needed any rows that has 'True' as text in column 8 to turn red. For Each lvi As ListViewItem In listKeys.Items If lvi.SubItems(8).Text = 'True' Then lvi.UseItemStyleForSubItems = False lvi.SubItems(8).ForeColor = Color.Red lvi.SubItems(7).ForeColor = Color.Red lvi.SubItems(6).ForeColor = Color.Red lvi.SubItems(5).ForeColor = Color.Red lvi.SubItems(4).ForeColor = Color.Red lvi.SubItems(3).ForeColor = Color.Red lvi.SubItems(2).ForeColor = Color.Red lvi.SubItems(1).ForeColor = Color.Red lvi.SubItems(0).ForeColor = Color.Red End If Next Hope this helps someone else along the way. Hey Ged, I have another row color problem.
The below code searches the listview and finds the row with a blue select high light. What I'm trying to do is make the row it finds green in color. I tried a lot of code to get this to work, but no go. It's much the same as lvi.UseItemStyleForSubItems = False and lvi.SubItems(1).ForeColor = Color.Red' but isn't working for me. Any help would be great.
![C# listview edit subitem C# listview edit subitem](http://3.bp.blogspot.com/-SBpgrVBFq4o/TcJIIvjDfUI/AAAAAAAAANs/gf37snLdDBE/s640/Untitled-1.jpg)
Private Sub Button1Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click SearchListView(listKeys, txtSearchKeys.Text) End Sub' Private lastSearch As String = ' Private lastIndex As Integer = -1' Private Sub SearchListView(ByVal listView As ListView, ByVal txtFind As String) Dim foundItem As ListViewItem = Nothing If lastSearch = txtFind Then If lastIndex.