-
How to format a string?
I'm looking for a way to format a string. Is there a way to format a string that will be shown in a textbox?
Here's what I want to do.
Code:
Dim strName As String
strName = "Company Name:" & vbCrLf & _
"University of Winsconsin Stout" & vbCrLf vbCrLf & _
"Department:" & vbCrLf & _
"Development"
txtbox1.text = strName
In the above code, I want to bold the heading "Company Name:" and "Department:" and then italicize the "University of Wincosin Stout" and "Development".
Is there a to format this at run time with code?
ljCharlie
-
I don't think you can do this on a textBox . If RichTextBox won't do this , then DrawString will do it [GDI+].
-
Thanks, Pirate!
I just thought I give it a try. Well, it's okay.
ljCharlie
-
By the way, Pirate, do you know a way to write the texts to a textbox or richtextbox in design time? I want to write the About and Help section of my application in design mode, but I couldn't find an easier way to do it.
Thanks!
ljCharlie
-
What about writing it in a text file , then load it after your application is launched . I think even MS follow this convention .
-
Perhaps textbox won't do it but richtextbox will retain my format such as bold, italics, tab, and things of that nature if a load the file in run time, right?
ljCharlie
-
If you wrote and formatted the text (bold , colored ...) in rtf files , then you loaded it in RTF control, sure it will pertain everything .
-
One other question. I know this can be done but I don't know how to do it. When I load the RTF file from the directory, how do I read the information in that file? For example, I have topics such as Introduction, Updating, Inserting, Deleting. When the user click on the Updating topic, how do I load just the Updating section into my richtextbox from the file and kept the rest from loading into the richtextbox? I know that I would have to format my RTF file in such a way that there is a unique charactor before the next topic section start...but I don't know how to read from the file and determine that unique charactor to start and stop loading into the textbox.
Sorry for asking too much of you, but I really do need help.
Many thanks for your help.
ljCharlie
-
1 Attachment(s)
Here's a quick domo with commented code .
-
Thanks, Pirate. I'll give that look next week. I'm off for the weekend.
ljCharlie
-
I gave your sample a try and it does pretty much what I wanted to do; however, I couldn't get each section to load individually. Every time when I want to load, let's say, Deleteing section, the Introduction section and any section that is above the Deleting section will also appear in the richtextbox. Is there a way to fix this problem? Right now the problem is that all section that is before the specify section appear in the rtf box and I only want the section that I choose to load.
ljCharlie