我有以下代码:
Dim useFont As Font = e.Font
Dim myBrush As Brush = Brushes.Black
' Determine the font to draw each item based on
' the index of the item to draw.
If e.Index = 0 Or 7 Or 10 Or 13 Then
useFont = New Font(e.Font, FontStyle.Bold)
Else
useFont = DefaultFont
End If
' Select e.Index
' Case 0
'useFont = New Font(e.Font, FontStyle.Bold)
' Case 7
'useFont = New Font(e.Font, FontStyle.Bold)
' Case 10
'useFont = New Font(e.Font, FontStyle.Bold)
' Case 13
'useFont = New Font(e.Font, FontStyle.Bold)
'End Select
下面注释掉的代码是我旧的工作代码。我认为我最好重写它以使其更紧凑和可读,但是我无法弄清楚如何执行与case select相同的功能,因为它只会导致我的所有列表项变为粗体。我不知道我是否只是误解了OR运算符,而且OrElse也不起作用。
有人可以给我一些正确方向的指示吗?感谢。
答案 0 :(得分:3)
If e.Index = 0 Or e.Index= 7 Or e.index=10 Or e.index=13 Then
但你可以同样做到
Case 0,7,10,13