追加しようとしているアイテムのテキストまたはそれに含まれるテキストに基づいて、リストボックスに各アイテムを描画する必要があります。次に、リストボックスの先頭にアイコンを配置する必要があります。指定した単語に応じて、他の 2 つの色とアイコンを配置します。
項目にエラー テキストが含まれている場合は、エラー (16x16 ピクセル) アイコンを先頭に配置し、背景を薄い赤で、テキストを太い濃い赤で描画します。
準備完了または開始テキストが含まれている場合は、明るいオレンジ色の背景と濃い太字の青色のテキストを使用します。
- OK または成功のテキストが含まれている場合は、明るい緑色の背景と濃い太字の緑色のフォント テキストを使用します。
これどうやってするの?
編集
これは私がすでに持っているものですが、このコードは無限に更新されるようです。色を選択する必要があるのは、e.index の値です。e.index を e.stringvalue のような somthinf に変更できますか?
Private Sub lsbLog_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles lsbLog.DrawItem
'//Draw the background of the ListBox control for each item.
'// Create a new Brush and initialize to a Black colored brush
'// by default.
e.DrawBackground()
Dim mybrush = Brushes.Black
'// Determine the color of the brush to draw each item based on
'//the index of the item to draw.
Select Case e.Index
Case 0
mybrush = Brushes.Red
Case 1
mybrush = Brushes.Blue
Case 2
mybrush = Brushes.Green
End Select
'//
'// Draw the current item text based on the current
'// Font and the custom brush settings.
'//
e.Graphics.DrawString(lsbLog.Items(e.Index).ToString(), _
e.Font, mybrush, e.Bounds, StringFormat.GenericDefault)
'//
'// If the ListBox has focus, draw a focus rectangle
'// around the selected item.
'//
e.DrawFocusRectangle()
lsbLog.Refresh()
End Sub