|
-
Apr 11th, 2004, 04:56 AM
#1
Thread Starter
Frenzied Member
Populating listview
I guess this will be fairly tricky(maybe not) so i'm hoping somebody knows of a tutorial or pre-made code for populating a listview from a text list.
My text list data has 2 delimiters "|" and "," and is of the form
path filename|filesize,path filename|filesize etc
example being c:\file1.exe|34502,c:\file2.exe|31233..etc.
Well my task is to read any length of list, as in the example, and display in a suitable way.
-
Apr 11th, 2004, 08:06 AM
#2
Thread Starter
Frenzied Member
I sorted most of this out apart from one thing, how to you extract part of a string that lies inbetween 2 different delimiters?
like ,file1.exe|32123,file2.exe|432432,
So i need the split to start at the "," and stop at the "|" so as to extract the file size .
I need a kinda reverse Mid that allows characters delims.
Last edited by Jmacp; Apr 11th, 2004 at 08:09 AM.
-
Apr 11th, 2004, 08:40 AM
#3
Split first on "," you'll get an array from that, say arrFirst(). To assign the pair into separate columns in the listview, loop through arrFirst, split each line on "|" and assign the result to .Text = arrSecond(0) .SubItem(1) = arrSecond(1)
-
Apr 11th, 2004, 04:29 PM
#4
Thread Starter
Frenzied Member
I keep on getting runtime error 9, out of subscript, i think whats happeneing is its running through the loop one more time than it should, hard to explain but i can't seem to fit a condition in to stop the loop at a certain length.
Anybody know of any code that would fit this situation, it has to be able to parse a string with 2 delims and populate the listview with the filename in one columm and the respective filesize in the other.
my string is in the form,
VB Code:
....test.exe|6327,text2.exe|4776,test3.exe....and on|
-
Apr 11th, 2004, 04:32 PM
#5
Do you have to put them in columns? Can you just put them as subitems of listview items and use HitTest to get their values?
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 11th, 2004, 05:40 PM
#6
Frenzied Member
Use Replace first
c:\file1.exe|34502,c:\file2.exe|31233..etc.
Replace either the | with , or vice versa so the delimter is the same. Then Split it into an Array.
-
Apr 11th, 2004, 05:47 PM
#7
Originally posted by BrianS
Use Replace first
c:\file1.exe|34502,c:\file2.exe|31233..etc.
Replace either the | with , or vice versa so the delimter is the same. Then Split it into an Array.
And step through the loop in 2s instead of the default 1
-
Apr 11th, 2004, 06:37 PM
#8
Thread Starter
Frenzied Member
I got it, thanks.
One more thing, the scrollbar doesn't appear in the listview when the list exceeds the height. I am using this(below), to auto resize the listview and treeview if that makes a difference,
VB Code:
Public Sub Form_Resize()
lvFiles.Width = Me.Width
lvFiles.Height = Me.Height
TvTreeView.Height = Me.Height
End Sub
In fact it doesnt appear even if i don't resize.
-
Apr 12th, 2004, 09:58 AM
#9
Thread Starter
Frenzied Member
Anybody know how to get the vertical and idealy horizontal scrollbar to appear in my listview, it doesn't by default and there doesn't seem to be an option to add one in the properties ?
-
Apr 12th, 2004, 10:37 AM
#10
Fanatic Member
I am really curious...never seen the listview do this - is it possible for you to upload your project?
"Knowledge is gained when different people look at the same information in different ways"
- Louis Pasteur
-
Apr 12th, 2004, 11:30 AM
#11
If your Listview and Treeview controls are side by side on the Form, then the width of the Listview should take into account the width of the Treeview.
I think the listview is extending off the form, the scrollbars are offscreen.
This assumes the Treeview is on the left side and Listview is on the right.
VB Code:
Public Sub Form_Resize()
If WindowState <> vbMinimized then
If Me.ScaleWidth > tvTreeview.Width + 100 'otherwise an error if the form is resized smaller than the width of the treeview
lvFiles.Width = Me.ScaleWidth - tvTreeview.Width
End If
lvFiles.Height = Me.ScaleHeight
TvTreeView.Height = Me.ScaleHeight
End If
End Sub
Use the ScaleWidth and ScaleHeight properties of the Form instead. They represent the client area of the form. I.E. they do not include the title bar , borders, menus etc..
Last edited by brucevde; Apr 12th, 2004 at 11:33 AM.
-
Apr 12th, 2004, 01:45 PM
#12
Thread Starter
Frenzied Member
Ok thanks thats what i thought might be happening but i've just taken the form resize out and still no scrollbar, shouldn't the scrollbar appear automatically ?
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
|