salve a tutti
io uso questo codice per il caratter dentro al toolstrip:
Dim font As New Drawing.Text.InstalledFontCollection
Dim b As String = ""
For Each s As FontFamily In font.Families
b = s.Name
toolstrip.Items.Add(b)
Next
pero quando carico un file vorrei che nel toolstrip mi venisse scritto il carattere
che usa quel file (rtf)
Non è proprio semplice... Premetto che questo lo devi fare manualmente, ossia non esiste nessuna proprietà o metodo preimpostati che ti permettano di farlo. Devi cambiare la proprietà DrawMode del toolstrip su OwnerDrawFixed (è un combobox, giusto?). Quindi, nell'evento DrawItem, devi scrivere il codice per stampare un dato elemento con un dato font. Per fare questo ti serve memorizzare la lista di font installati.
Class Form1
Private Fonts As New List(Of Font)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each f As FontFamily In (New Drawing.Text.InstalledFontCollection()).Families
Try
Dim Fnt As New Font(f.Name, 12, FontStyle.Regular)
Fonts.Add(Fnt)
ComboBox1.Items.Add(f.Name)
Catch Ex As Exception
End Try
Next
End Sub
Private Sub ComboBox1_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
e.Graphics.DrawString(ComboBox1.Items(e.Index), Fonts(e.Index), Brushes.Black, e.Bounds.X, e.Bounds.Y)
End Sub
End Class
Quindi, nell'evento DrawItem, devi scrivere il codice per stampare un dato elemento con un dato font. Per fare questo ti serve memorizzare la lista di font installati.
Potresti spiegarti meglio nn sn molto esperto col vb net