Hello, David:
I suggest you use System.Drawing to draw boxes because most of the fonts don't support the graphic characters, some support them through char sets (like Microsoft Sans Serif) and few support it directly (like Arial)
You can learn how to use codepages in the internationalization documentation.
Anyway, here is an example. Create a form with a button and two textboxes. Set the Font property of TextBox1 to Arial and of TextBox2 to Microsoft Sans Serif. Leave the Font.GDICharSet property at the default value of zero for both TextBoxes. Past this code:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
'We need encoding for working with codepages:
Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding(437)
'TextBox1 uses Arial font.
'TextBox2 was assigned Microsoft Sans Serif with GDICharSet=0 at design time.
'TextBox1 is OK, but we must correct the font for TextBox2:
Me.TextBox2.Font = New Font(Me.TextBox2.Font.FontFamily, _
Me.TextBox2.Font.SizeInPoints, _
Me.TextBox2.Font.Style, _
GraphicsUnit.Point, _
255)
'Now the fonts are ready and both TextBoxes display correctly:
'We set from unicode (ChrW),
' from codepage 437 (enc.GetString)
' and inline ("┼â•â•‘") (keyboard: Alt+2501, Alt+2509, Alt+2490).
Me.TextBox1.Text = ChrW(&H255E) & ChrW(&H256A) & ChrW(&H256C) & ChrW(&H2563) _
& enc.GetString(New Byte() {32, &HC6, &HD8, &HCE, &HB9}) _
& " ─│┌â”└┘├┤┬┴┼â•â•‘╒╓╔╕╖╗╘╙╚╛╜â•â•žâ•Ÿâ• ╡╢╣╤╥╦╧╨╩╪╫╬▀▄█▌â–â–‘â–’â–“"
Me.TextBox2.Text = ChrW(&H255E) & ChrW(&H256A) & ChrW(&H256C) & ChrW(&H2563) _
& enc.GetString(New Byte() {32, &HC6, &HD8, &HCE, &HB9}) _
& " ─│┌â”└┘├┤┬┴┼â•â•‘╒╓╔╕╖╗╘╙╚╛╜â•â•žâ•Ÿâ• ╡╢╣╤╥╦╧╨╩╪╫╬▀▄█▌â–â–‘â–’â–“"
End Sub
Now, if you delete the "Me.TextBox2.Font = ..." statement, you will see that TextBox2 displays only empty boxes.
Of course, you can set Font.GDICharSet to 255 at design time.
You can use the charmap to see the codes corresponding to the graphic characters and if a font of your system supports them.
Note that this message has been coded with UTF-8 in order to keep the graphic characters. When you use special characters inline, you must save the code file (*.vb) encoding it, for example, with UTF-8, or other coding that supports the special characters.
Note also that Windows 98 and Me TextBoxes are not fully compatible with Unicode and "┼â•â•‘" might be displayed as "+-|"
Regards.
"David Scemama" <
[email protected]> escribió en el mensaje | Hi,
|
| I'm looking for a way to display semi graphic characters in a multi line
| text control or in a rich text control.
| I've tried with all the characters of the extended ASCII table (code page
| 437), they appear correctly except the semi graphic ones.
|
| Please help ...
|
| Thanks a lot
| David