|
-
Feb 28th, 2009, 01:48 PM
#1
Thread Starter
Fanatic Member
[2008] Help with TreeView
Hi, i'm trying to use the treeview to display the text of a rtf (rich text file) file when an specific node if clicked.
Home
OMG WOOT
For example, if i pick OMG, i want the text of lol.rtf to be displayed on a richtextbox. But somehow i just can't manage to get it... I know to import the text of a .txt file to a textbox, but using the treeview makes it more complicated.
This is the code im using right now:
Code:
Private Sub TreeView1_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
Select Case e.Node.Index
Case 0
Dim file As String
file = My.Computer.FileSystem.ReadAllText(filename)
RichTextBox1.Text = file
Case 1
'Same code, different file name
Case 2
'Same code, different file name
Case 3
'Same code, different file name
Case 4
'Same code, different file name
End Select
End Sub
Another thing is, that i can't import the *.rtf text into a richtextbox and i don't know why.
Last edited by tassa; Feb 28th, 2009 at 02:10 PM.
-
Feb 28th, 2009, 03:16 PM
#2
Re: [2008] Help with TreeView
To import an rtf into RTB try this
vb Code:
Dim strfilename As String
With OpenFileDialog1
.Filter = "RICHTEXT FILES (*.rtf) |*.rtf"
.FilterIndex = 1
.InitialDirectory = "c:\"
.Title = "OPEN FILE"
.FileName = ""
End With
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
strfilename = OpenFileDialog1.FileName
Dim OBJREADER As StreamReader = New StreamReader(STRFILENAME)
richTextBox1.Text = OBJREADER.ReadLine
End If
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Mar 1st, 2009, 11:50 AM
#3
Thread Starter
Fanatic Member
Re: [2008] Help with TreeView
Yeah, it KINDA worked, because it only imported a bunch of gibberish. It's probably the file.
-
Mar 1st, 2009, 11:57 AM
#4
Re: [2008] Help with TreeView
To read RTF into a RichTextBox you need to do;
RichTextBox1.LoadFile(FileName, RichTextBoxStreamType.RichText)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|