Hi all,
It may sound esoteric, but actually it is. Let's say there is a string
resource in a project, the value is "AA BB". How can I only format the"BB"
part into bold type. Can I finish the format when I input the string intothe
resouce instead of using coding?
Clara
Hi Clara,
After you added your string into your resource(Through Project
Settings -> Resources), let's say it's named as "String1" and its
value is "AA BB", you can get the last two letter using substring
function, that is "BB", then make it bold using a new font instance,
and finally bring AA next to BB using two seperate controls. (in that
sample, a label).
However, the part that i wonder and have to guess is that if you're
using a Label or other control to show your string. For instance, if
you want to show your string in your label with formatting(making
bold) the "AA" part, i'm afraid you need to use 2 labels and first one
will show "AA" and the other one will show "BB", and you need to bring
Label2(which holds BB) next to Label1 in designer.
So the code that i wrote as what i understood from your issue:
' Keep "AA" as original without making bold
' Optionaly make AA's size same as BB
Label1.Font = New Font("Arial", 10, FontStyle.Regular)
Label1.Text = My.Resources.String1.Substring(0, 2)
' Set BB's font to bold
Label2.Font = New Font("Arial", 10, FontStyle.Bold)
Label2.Text = My.Resources.String1.Substring(3, 2)
' That code brings Label2 next to Label1
' to have a display as if AA and BB are together.
Label2.Location = New Point(Label1.Location.X + Label1.Width,
Label2.Location.Y)
I'm not sure if this is what you're looking for, but i hope it makes
some sense to make you think of the steps that you can take.
Onur Güzel