Forum: VB.NET |
Thema:
Re: listbox einträge highlighten |
Von:
G. Guest (
05.02.2005 14:53) |
hi,
hab was im VB.NET Codebook gefunden.
Private Sub LBFonts_MeasureItem(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.MeasureItemEventArgs) _
Handles LBFonts.MeasureItem
' Anzuzeigendes Objekt
Dim font As Font = DirectCast(LBFonts.Items(e.Index), Font)
' Darstellungsgröße berechnen
Dim sz As SizeF = e.Graphics.MeasureString(font.Name & " " & _
font.SizeInPoints, font)
' Information an ListBox weitergeben
e.ItemHeight = CInt(sz.Height)
e.ItemWidth = CInt(sz.Width)
End Sub
Private Sub LBFonts_DrawItem(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.DrawItemEventArgs) _
Handles LBFonts.DrawItem
' Anzuzeigendes Objekt
Dim font As Font = DirectCast(LBFonts.Items(e.Index), Font)
' Brush für Darstellung der Schrift
Dim fbr As Brush = New SolidBrush(e.ForeColor)
' Hintergrund zeichnen
e.DrawBackground()
' Textausgabe
e.Graphics.DrawString(font.Name & " " & font.SizeInPoints, _
font, fbr, e.Bounds.X, e.Bounds.Y)
' Ressourcen freigeben
fbr.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' Zu Beginn einige Schrifarten in die Liste aufnehmen
LBFonts.Items.Add(New Font("Arial", 10))
LBFonts.Items.Add(New Font("Arial", 20))
LBFonts.Items.Add(New Font("Arial", 30))
LBFonts.Items.Add(New Font("Times", 10))
LBFonts.Items.Add(New Font("Times", 20))
LBFonts.Items.Add(New Font("Times", 30))
End Sub
kann dir leider über diese plattform keine ganze solution schicken. die solution aus der ich den code habe funktioniert.
gruss
frank
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!