473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to format a string in resource

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 into the
resouce instead of using coding?

Clara
--
thank you so much for your help
Nov 12 '08 #1
4 3967
On Nov 12, 7:09*pm, clara <cl...@discussions.microsoft.comwrote:
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
--
thank you so much for your help
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
Nov 12 '08 #2
On Nov 12, 8:29*pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Nov 12, 7:09*pm, clara <cl...@discussions.microsoft.comwrote:
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 into the
resouce instead of using coding?
Clara
--
thank you so much for your help

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
I want to update the last line, assuming your labels' initial
positions are different in designer and that would be more useful:

Label2.Location = New Point(Label1.Location.X + Label1.Width, _
Label1.Location.Y)

Again, positioning algorithm depends how you and what you use to
display your strings and i assumed you're using them on your form, eg:
using a label.

HTH,

Onur Güzel
Nov 12 '08 #3
Hi Kimiraikkonen,

Thank you very much for your edifying reply! It helps me much!

Clara
--
thank you so much for your help
"kimiraikkonen" wrote:
On Nov 12, 7:09 pm, clara <cl...@discussions.microsoft.comwrote:
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 into the
resouce instead of using coding?

Clara
--
thank you so much for your help

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
Nov 12 '08 #4
"clara" <cl***@discussions.microsoft.comschrieb:
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 into
the
resouce instead of using coding?
You could format the string using RTF codes and then use the RichTextBox
control to display the string.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 12 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Adam Parkin | last post by:
Hello all, I am seeking some help with the following problem. I'm working on an application where I have a resource file, and in this resource file what I want to store is a list of file names...
10
by: .Net_Newbie | last post by:
Hello, gurus I have a problem about format XML I use ms data access building block to get a data set from stored procedure. the dataset's save xml give me data with the elements. Is there any...
11
by: Dale | last post by:
How to recognize whether file has XML format or not? Here is the code segment: XmlDocument* pDomDocument = new XmlDocument(); try { pDomDocument->Load(strFileName ) ; } catch(Exception* e) {
23
by: Matt Garman | last post by:
Is there a clean, portable way to determine the maximum value of converted numerical fields with printf()-like functions? Doing this at compile-time would be preferable. For example, %i should...
2
by: Sam Martin | last post by:
from a resource file. Hi all, Im having a bit of a moment. I've got resource files in each of my assemblies, just named like "Labels.resources" for example. I've got a commond base...
7
by: Edward Mitchell | last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a format of Time. The controls are all embedded in dialogs. I created the controls by dragging the DateTime picker from...
3
by: mavrick101 | last post by:
Why is String.format better than just concatenating the string? is it just the cost of creating a new string? or any thing more?
4
by: David Morris | last post by:
Hi Could somebody please explain what the following line of code means String.Format("{0}\{1}.{2:00}", C:\, myfile.txt, 1 It's actually the first argument that I don't understand. What is...
4
by: Peter Larsen [] | last post by:
Hi, How do i read a resource string from a dll in code ?? BR Peter
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.