Listview check for space infront of text

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Hello i need help with a listview i have added some text but i want it to see what lines there are spaces before words and then color the row, is this possible if so how ?
https://t.me/pump_upp
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

i dont know how to check if space but this will help you to check if emphty
Code: Select all
If ListView1.ListItems.Count = 0 Then
    Msgbox "ListView is empty"
Else
    Msgbox "Listview contains " & ListView1.ListItems.Count & " items"
End If
Find my programs on Softpedia
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

This might be able to help you:
Code: Select all
Dim item As ListViewItem
For Each item In ListView1.Items
     If item.Text.Substring(0,1)=" " Then item.BackColor=Color.Red
Next
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

comathi wrote:
This might be able to help you:
Code: Select all
Dim item As ListViewItem
For Each item In ListView1.Items
     If item.Text.Substring(0,1)=" " Then item.BackColor=Color.Red
Next
How would i do so its those without space that gets colored only ?
https://t.me/pump_upp
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Simple, just add a Not in front of the IF condition:
Code: Select all
Dim item As ListViewItem
For Each item In ListView1.Items
     If Not item.Text.Substring(0,1)=" " Then item.BackColor=Color.Red
Next
5 posts Page 1 of 1
Return to “Coding Help & Support”