|
-
May 8th, 2012, 04:31 AM
#1
Thread Starter
PowerPoster
[RESOLVED] Add nodes treeview drag-drop textfile
Hi,
I have a simple textfile which I want to drag-drop into the treeview. After the drop read the textfile (line by line) and create the nodes. There are no subnodes (what-so-ever). File looks like this:
line1
line2
line3
line4
Any suggestions/examples?
-
May 8th, 2012, 05:22 AM
#2
Hyperactive Member
Re: Add nodes treeview drag-drop textfile
Rico
Using: VB.net & MS SQL
-
May 8th, 2012, 05:25 AM
#3
Thread Starter
PowerPoster
Re: Add nodes treeview drag-drop textfile
If it were that simple I wouldn't ask. Besides that, I probably need to Peek(). How to add the nodes according the textfile?
-
May 8th, 2012, 05:25 AM
#4
Re: Add nodes treeview drag-drop textfile
try this:
vb Code:
Public Class Form1
Private Sub TreeView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim file As String = DirectCast(e.Data.GetData(DataFormats.FileDrop), String()).First
Dim lines() As String = IO.File.ReadAllLines(file)
For Each line As String In lines
TreeView1.Nodes.Add(line, line)
Next
End If
End Sub
Private Sub TreeView1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView1.DragOver
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.All
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TreeView1.AllowDrop = True
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 8th, 2012, 05:45 AM
#5
Thread Starter
PowerPoster
Re: Add nodes treeview drag-drop textfile
Thanks Paul. +REP deserved, but I can't give you at the moment unfortunately.
-
May 8th, 2012, 05:53 AM
#6
Re: [RESOLVED] Add nodes treeview drag-drop textfile
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
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
|