Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,091 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,815 people online right now. Registration is fast and FREE... Join Now!




Extended List

 
Reply to this topicStart new topic

Extended List, RichTextBox list

Damage
5 Jun, 2008 - 01:07 AM
Post #1

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 754



Thanked: 7 times
Dream Kudos: 75
My Contributions
Hi, i've just got a quick question. I've got a small app that I'm using to search for either specific files or files of a certain type. Thats not really the important part. The problem arises when i search for files by type, it returns a long list and populates a richtextbox lstBooks, it returns a long list (2149 i think) but it only displays the last part of the list. Whats the way around this?

CODE

    Private Sub btnDirectories_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDirectories.Click
        Dim drivestring As String = txtDrive.Text + ":\"
        Try
            listDirectories(drivestring)
        Catch ex As Exception
            MessageBox.Show("Invalid drive", "Tool", MessageBoxButtons.OK, MessageBoxIcon.Hand)
            MessageBox.Show("Exception thrown: " & ex.Message)
        End Try


    End Sub


    'Sub routine
    'Run on click of btnListDirectories
    '
    'Displays all directories on drive
    '
    'Args: drive as String, name of drive to search
    '
    'Populates list box lstDirectories
    '
    'Calls Function searchForFiles on each execution of loop


    Private Sub listDirectories(ByVal drive As String)
        'List each folder at the root of specified drive
        For Each strFolder As String In My.Computer.FileSystem.GetDirectories(drive)
            'Add the item to the list
            lstData.Items.Add(strFolder)
            If strFolder <> "d:\System Volume Information" Then

                'Search for books in directory
                'Me.lstBooks.Text = Me.SearchForFiles(strFolder, FileIO.SearchOption.SearchAllSubDirectories, "*.txt")


                Me.rtbTempBookList.Text = Me.SearchForFiles(strFolder, FileIO.SearchOption.SearchAllSubDirectories, "*.pdf")


            End If


        Next

        'Temporary message show number of returned files
        MessageBox.Show(tempCount)

    End Sub

    'Function
    'Run on each execution of loop in Sub listDirectories
    '
    'Displays all books, documents matching criteria
    '
    'Args: directory as string, name of directory to search
    '      searchOption as Microsoft.VisualBasic.FileIO.SearchOption, depth of search
    '      wildcards as string, any criterion the search needs to match
    '
    'Populates list box lstBooks
    '
    'Returns: returnValue as String, file names of files matching criteria  

    Protected Function SearchForFiles(ByVal directory As String, ByVal searchOption As Microsoft.VisualBasic.FileIO.SearchOption, ByVal wildCards As String) As String
        Dim returnValue As String = ""



        Try
            For Each foundFile As String In My.Computer.FileSystem.GetFiles(directory, searchOption, wildCards)
                returnValue &= foundFile & Environment.NewLine
                tempCount = tempCount + 1

            Next
        Catch ex As Exception
            MessageBox.Show("Exception thrown: " & ex.Message)
        End Try

        Return returnValue
    End Function

User is offlineProfile CardPM
+Quote Post

Damage
RE: Extended List
5 Jun, 2008 - 01:36 AM
Post #2

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 754



Thanked: 7 times
Dream Kudos: 75
My Contributions
okay just double checked and can i amend that to, not displaying properly at all

User is offlineProfile CardPM
+Quote Post

Damage
RE: Extended List
5 Jun, 2008 - 07:37 PM
Post #3

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 754



Thanked: 7 times
Dream Kudos: 75
My Contributions
well wasn't essential that i used a richtextbox so replaced it with a normal list box and used

lstBooks.Items.Add(foundFile)

seems to work fine, but for future reference is there a reason why the original wasn't working?
User is offlineProfile CardPM
+Quote Post

robertelder
RE: Extended List
6 Jun, 2008 - 05:50 AM
Post #4

New D.I.C Head
*

Joined: 5 Jun, 2008
Posts: 30



Thanked: 3 times
My Contributions
Damage,

I tried out your code, modifying it to search for MP3s since I don't have many PDFs on this computer.

MsgBox(tempcount) showed that it found 11927 items. I didn't count them all, but it lookes like each of their paths showed up in the RichTextBox.

The only thing I can think of that would cause it to show only the last part of the list is if the RichTextbox.Scrollbars property is set to NONE. Any chance of that?

Sorry I can't be much help on this one. Good luck!

-Rob



User is offlineProfile CardPM
+Quote Post

Damage
RE: Extended List
6 Jun, 2008 - 02:40 PM
Post #5

D.I.C Addict
Group Icon

Joined: 5 Jun, 2008
Posts: 754



Thanked: 7 times
Dream Kudos: 75
My Contributions
nope, wasn't that. Odd

But like i said, i was just using a richtextbox for curiosity's sake, wasn't essential, so i took it out and used a normal list box.

but thanks for having a look man, really appreciate it.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:02AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month