xsharp.eu • How to get regular + unicode character as button text (Winforms )
Page 1 of 1

How to get regular + unicode character as button text (Winforms )

Posted: Tue Feb 21, 2023 8:33 pm
by ic2
I want Ctrl and then (on the next line) an arrow symbol as button text (Winforms ).

I tried

Code: Select all

Self:MyButton:Text:="Ctrl"+crlf+"u2192"
(After seeing a C# question answered by: button1.Text = "Hello u2129" ;
but I get the literal text u2192 on the next line

How can I solve that?

Dick

How to get regular + unicode character as button text (Winforms )

Posted: Tue Feb 21, 2023 10:35 pm
by Chris
Hi Dick,

In c#, by default literal strings use escape sequences (special embedded codes starting with a ""), while in X# this is off by default. In order to specify that the a literal string should use such escape sequences, you must prefix it with "e". And since "r" standsfor LF and "n" for CR, you'd need to use

Code: Select all

Self:MyButton:Text := e"Ctrlrnu2129"
But I think showing an arrow this way is a bit ugly. Why don't you use and put a normal arrow bitmap on the button, together with the normal caption? In WinForms, it's a lot easier and more convenient to put an image on a button, in any way you like it, than it was in VO.

.

How to get regular + unicode character as button text (Winforms )

Posted: Wed Feb 22, 2023 8:40 am
by FFF
Chris post=25338 userid=313 wrote: since "r" standsfor LF and "n" for CR, you'd need to use
FTR, i think it is the other way round ;-)

How to get regular + unicode character as button text (Winforms )

Posted: Wed Feb 22, 2023 8:57 am
by Chris
FFF post=25340 userid=259 wrote:
Chris post=25338 userid=313 wrote: since "r" standsfor LF and "n" for CR, you'd need to use
FTR, i think it is the other way round ;-)
Oh, right! :)

.

How to get regular + unicode character as button text (Winforms )

Posted: Wed Feb 22, 2023 10:09 am
by ic2
Hello Chris,
Chris post=25338 userid=313 wrote: In c#, by default literal strings use escape sequences (special embedded codes starting with a ""), while in X# this is off by default. In order to specify that the a literal string should use such escape sequences, you must prefix it with "e". And since "r" standsfor LF and "n" for CR, you'd need to use

Code: Select all

Self:MyButton:Text := e"Ctrlrnu2129"
.

Splendid!
It also answers a question I had earlier: what is the meaning of the "e" I saw in some ILSpy converted code. Thanks for that.
Small remark: you wrote '2129' (the right arrow is is 2192)
Chris post=25338 userid=313 wrote: But I think showing an arrow this way is a bit ugly. Why don't you use and put a normal arrow bitmap on the button, together with the normal caption? In WinForms, it's a lot easier and more convenient to put an image on a button, in any way you like it, than it was in VO.
.
On the contrary. It looks exactly how it should look; adding a bitmap together with a text (Ctrl) often make it look a bit out of proportions. Besides: this is one line of code instead of having to first create a bitmap, add it somewhere, use it. If a font has a clear and meaningful symbol for something I prefer that much above using a bitmap.

Dick