我读过这篇文章 Appying Background Color to entire line of Text
这正是我需要的,但我正在使用VB.NET, 问题是 : 我应该如何在VB.NET中应用“listitem集合”?
感谢任何帮助。 最好的问候
答案 0 :(得分:0)
@Hans Passant 是的,你是对的,我已经改变了代码,现在它可以工作了。
Dim Linez As String() = New String(boxitem.Lines.Length - 1) {}
For i As Integer = 0 To boxitem.Lines.Length - 1
Linez(i) = boxitem.Lines(i) + New String(" ", 80)
Next
boxitem.Clear()
boxitem.Lines = Linez
For i As Integer = 0 To boxitem.Lines.Length - 1
Dim Linez1 As Integer = boxitem.GetFirstCharIndexFromLine(i)
boxitem.[Select](Linez1, boxitem.Lines(i).Length)
boxitem.SelectionBackColor = If((i Mod 2 = 0), Color.MistyRose, Color.Bisque)
Next
Try
boxitem.Select(boxitem.GetFirstCharIndexFromLine(boxitem.Lines.Length - 1),
boxitem.Lines(boxitem.Lines.Length - 1).Length)
Catch ex As Exception
End Try