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

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

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

Post 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
User avatar
Chris
Posts: 4907
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

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

Post 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.

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

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

Post 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 ;-)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
Chris
Posts: 4907
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

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

Post 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! :)

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

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

Post 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
Post Reply