Yazeka
Arama sonuçlarına göre oluşturuldu
ListBox'ta farklı renklendirmek için aşağıdaki yöntemler kullanılabilir:
- DrawMode property'si ve DrawItem event'i 35. ListBox'ın DrawMode property'sini OwnerDrawFixed olarak ayarlamak ve DrawItem event'ine müdahale etmek gerekir 35.
- Kod kullanımı 4. ListBox'taki belirli öğelerin arka planını renklendirmek için aşağıdaki kod kullanılabilir 4:
for (int i = 0; i < ListBox1.Items.Count; i++) { if (i % 2 == 0) { ListBox1.Items[i].Attributes.Add(“style”, “color:navy;background-color:aliceblue;”); } else { ListBox1.Items[i].Attributes.Add(“style”, “color:blue;background-color:skyblue;”); } }
ListBox1.DrawMode = DrawMode.OwnerDrawFixed e.DrawBackground() Dim brush As Brush = Brushes.Black Select Case e.Index Case 0 brush = Brushes.Red Exit Select Case 1 brush = Brushes.Orange Exit Select Case 2 brush = Brushes.Purple Exit Select Case 3 brush = Brushes.Blue Exit Select Case 4 brush = Brushes.Olive Exit Select Case 5 brush = Brushes.White Exit Select End Select e.Graphics.DrawString(DirectCast(sender, ListBox).Items(e.Index).ToString(), e.Font, brush, e.Bounds, StringFormat.GenericDefault) e.DrawFocusRectangle()
Bu tür özelleştirmeler için bir programlama dili (örneğin, C# veya VB.NET) ve ilgili kütüphanelerin kullanılması gerekebilir.
5 kaynaktan alınan bilgiyle göre: