Software Development Network>> Smart Devicet>> Change font in ListBox
Hi Tan .NetCF,
to change the font style at runtime, you should reset the font of the control like the following:
(form1 will have a combobox1 filled with items, and the code below will change the font to Courier with Bold style)
Private
ComboBox1.Font = New System.Drawing.Font("Courier New", 9.0!, System.Drawing.FontStyle.Bold)
End
good luck
mario aoun
Try looking at the MSDN docs for Listbox. The font property can be found here:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.listbox.font.aspx
You can use this with the same code as above except with a listbox.
Also if you press F1 while you are in Visual Studio a world of knowledge will appear
JR Lyon,
Can I set bold for 1st line and italic for 2nd line for example
Hi Tan,
what you're looking for is an owner-drawn ListBox.
That could be done with the DrawMode property:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.listbox.drawmode.aspx
Unfortunately this property is not supported in the Compact Framework, so a solution
could be writing your own Custom Control implementing a list of items, each with its own Font.
Gian Paolo Costantino
Change font in ListBox
MMDG
milicica
Hi Tan .NetCF,
to change the font style at runtime, you should reset the font of the control like the following:
(form1 will have a combobox1 filled with items, and the code below will change the font to Courier with Bold style)
Private
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadComboBox1.Font = New System.Drawing.Font("Courier New", 9.0!, System.Drawing.FontStyle.Bold)
End
Subgood luck
mario aoun
akin_l
Harry_Leboeuf
Try looking at the MSDN docs for Listbox. The font property can be found here:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.listbox.font.aspx
You can use this with the same code as above except with a listbox.
Also if you press F1 while you are in Visual Studio a world of knowledge will appear
Mike Haro
JR Lyon,
Can I set bold for 1st line and italic for 2nd line for example
Kinlan
Hi Tan,
what you're looking for is an owner-drawn ListBox.
That could be done with the DrawMode property:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.listbox.drawmode.aspx
Unfortunately this property is not supported in the Compact Framework, so a solution
could be writing your own Custom Control implementing a list of items, each with its own Font.
Gian Paolo Costantino