What's Here?
- Members: 340,154
- Replies: 920,531
- Topics: 154,951
- Snippets: 4,855
- Tutorials: 1,257
- Total Online: 3,961
- Members: 114
- Guests: 3,847
|
Welcome to Dream.In.Code |
|
|
Become an Expert!
Join 340,154 Programmers for FREE! Get instant access to thousands  of experts, tutorials, code snippets, and more! There are 3,961 people online right now. Registration is fast and FREE... Join Now!
Chat LIVE With a Expert
|
Rich Text Box trouble
Rich Text Box trouble
Formatting i think....
Rate Topic:
   
Posted 20 April 2009 - 07:01 PM
Ok so im designing a program that will read from various text files (preferably RTF files) and then put them into the RTF box in the program when a button is clicked.
Here is the portion of my code that i am referring to.
Try
Dim fileText As String = My.Computer.FileSystem.ReadAllText("c:\" & selectedHero & ".rtf")
infoDisplay.AppendText(fileText)
infoDisplay.Rtf.Format()
Catch
MsgBox("Selected Hero currently has no File with us.")
End Try
Now heres the problem. In the file i have a few pictures and its formatted and what not. I thought since its a RTF file and the Box is RTF it would auto format.... but anyways. It appears like this in the RTF Box.
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20{\object\objemb{\*\objclass Paint.Picture}\objw3000\objh3000{\*\objdata
01050000
02000000
07000000
50427275736800
00000000
00000000
00d50100
424df6d40100000000003600000028000000c8000000c80000000100180000000000c0d4010000
000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Ok so im not sure how i can read from a RTF file and put it in the RTF box with the right format.... any ideas? Ive been searching around for a while.
Posted 20 April 2009 - 07:17 PM
Edit: Post was a VB6.
This post has been edited by firebolt: 20 April 2009 - 07:40 PM
Posted 20 April 2009 - 07:31 PM
Anyways... back on the ranch
If anyone could help that would be awsome.
Posted 20 April 2009 - 07:38 PM
Moved to VB.NET.
@ firebolt SoloFrog used the correct syntax to show the message box. If you are using MsgBox instead of MessageBox.Show, parantheses are required.
@ SoloFrog What exactly is wrong with the formatting? Is it displayed in the wrong order (layout problems) or doesn't correctly display the formatting (for example, no pictures)?

- apt-get install DIC.bin
-
-
Group:
Admins
-
Posts:
16,214
-
Joined:
26-July 07
Dream Kudos: 12400
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery
Posted 20 April 2009 - 07:56 PM
@SoloFrog: Try this
Try
Dim fileText As String = My.Computer.FileSystem.ReadAllText("c:\" & selectedHero & ".rtf")
infoDisplay.Rtf= fileText
Dim s As String = infoDisplay.Text
infoDisplay.AppendText(s)
Catch
MsgBox("Selected Hero currently has no File with us.")
End Try
That should remove the RTF formatting?
Posted 20 April 2009 - 08:42 PM
@Core
Basically my code is outputting that second box in the RTF box. All that code there is supposed to be a simple picture, but its not formatting it basically.
@PsychoCoder
I tried that and to no prevail
Thanks guys for speedy responses

- apt-get install DIC.bin
-
-
Group:
Admins
-
Posts:
16,214
-
Joined:
26-July 07
Dream Kudos: 12400
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery
Posted 20 April 2009 - 08:58 PM
@SoloFrog: So you're trying to put an image in a RichTextBox?
Posted 21 April 2009 - 06:43 AM
@PsychoCoder No, well im trying to read from a RTF file that HAS a image in it, and then when i put the said file and its content into a Visual Basic RTF Box, all it does is show that code instead of the picture. How can i get it to hide the formatting?
Posted 21 April 2009 - 08:37 AM
Like i just dont see why a RTF Box in VB would not be able to use the formatting of a RTF file.... or maybe im missing something or some option?
Posted 21 April 2009 - 06:56 PM
Following some advice from a teacher out at the college i mixed my code up and came up with this
Try
Dim FileDB As New OpenFileDialog()
FileDB.Filter = "All Files|*.*|RTF FILES|*.rtf"
FileDB.FilterIndex = 2
FileDB.InitialDirectory = "C:\"
infoDisplay.LoadFile(FileDB.FileName)
Catch
MsgBox("Selected Hero currently has no File with us.")
End Try
Still doing the same thing. It must be some kind of format option or something to do with the actual text box that im missing. If anyone has any ideas. Let me know.
1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users
|
Be Social
Programming
Web Development
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|