ashgopal2000
Member
- Joined
- Jun 24, 2005
- Messages
- 12
- Programming Experience
- 1-3
Hi,
I have been designing some Window Forms with VB.NET.
I have a listbox control and a label on top to display the headers for the listbox items.
On resizing the form, the font sizes of the displayed text are not automatically resized. So, I initialize the fontsize of the texts as follows:
Label.font = new font(“Courier New”, font_size, FontStyle.Bold)
Lstbox.font = new font(“Courier New”, font_size, FontStyle.Bold)
Where font_size is calculated by another logic, which is not relevant here.
Now even though I use “Courier New” font, I get different character width in the Label and the listbox for the same font size.
A more detailed code is:
lbW = Label8.Width
lbH = Label8.Height
Label8.Font = New Font("Courier New", font_size, FontStyle.Bold)
‘get back the original size, in case the font has been resized
‘This does not affect the font size
Label8.Size = New Size(lbW, lbH)
lbW = lstAgedCase.Width
lbH = lstAgedCase.Height
lstAgedCase.Font = New Font("courier new", font_size, FontStyle.Bold)
lstAgedCase.Size = New Size(lbW, lbH)
But, when I display the font size of the listbox and the label after this statement, I find that they have the same font sizes.
I have been battling with this problem for weeks and any attempt to help on this will be highly appreciated. Is there a way to display a text of a particular character width?
Thanks
I have been designing some Window Forms with VB.NET.
I have a listbox control and a label on top to display the headers for the listbox items.
On resizing the form, the font sizes of the displayed text are not automatically resized. So, I initialize the fontsize of the texts as follows:
Label.font = new font(“Courier New”, font_size, FontStyle.Bold)
Lstbox.font = new font(“Courier New”, font_size, FontStyle.Bold)
Where font_size is calculated by another logic, which is not relevant here.
Now even though I use “Courier New” font, I get different character width in the Label and the listbox for the same font size.
A more detailed code is:
lbW = Label8.Width
lbH = Label8.Height
Label8.Font = New Font("Courier New", font_size, FontStyle.Bold)
‘get back the original size, in case the font has been resized
‘This does not affect the font size
Label8.Size = New Size(lbW, lbH)
lbW = lstAgedCase.Width
lbH = lstAgedCase.Height
lstAgedCase.Font = New Font("courier new", font_size, FontStyle.Bold)
lstAgedCase.Size = New Size(lbW, lbH)
But, when I display the font size of the listbox and the label after this statement, I find that they have the same font sizes.
I have been battling with this problem for weeks and any attempt to help on this will be highly appreciated. Is there a way to display a text of a particular character width?
Thanks