CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Join Date
    Sep 2018
    Posts
    38

    Re: FileSystemWatcher .Path string

    Quote Originally Posted by Arjay View Post
    There a a few approaches. One is you bind the ui list to your underlying list collection. The the click can access the current item in the list. If you aren't binding, then when you insert the ui list rows from the list collection, add a tag with the index to the current list position. When a click occurs, retrieve the tag value and use it to retrieve the item.
    Sounds like binding the ui list to the collection is the more concise approach. I've done some binding of data before, but I don't know if it's what you're referring to.

    This topic has sort of deviated from the original title...should it be moved into a new thread to accommodate the new topic of interest?

  2. #17
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: FileSystemWatcher .Path string

    No need to move the thread. How are you displaying the list in the ui (feel free to start a new thread if you like)?

  3. #18
    Join Date
    Sep 2018
    Posts
    38

    Re: FileSystemWatcher .Path string

    Quote Originally Posted by Arjay View Post
    No need to move the thread. How are you displaying the list in the ui (feel free to start a new thread if you like)?
    Up to this point I haven't used the list for the ui. The only plan I had for it was to recall the plan object and enable or disable it from the list. I update the ui when there are changes, but that's done reading the database. I probably need more experience with lists. Give me your input on it.

  4. #19
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: FileSystemWatcher .Path string

    Quote Originally Posted by KGCole View Post
    Up to this point I haven't used the list for the ui. The only plan I had for it was to recall the plan object and enable or disable it from the list. I update the ui when there are changes, but that's done reading the database. I probably need more experience with lists. Give me your input on it.
    It depends on how you've implemented your ui list. Zip up a sample solution that shows how a list of items is displayed on a ui. Then I can help you.

  5. #20
    Join Date
    Sep 2018
    Posts
    38

    Re: FileSystemWatcher .Path string

    Here's the basic method I use to read my database into the listbox. Nothing fancy, just using OleDbDataReader to feed items into the list:

    Code:
       Public Sub GetPlans()
    
            Dim myConn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\..\Resources\BakDb.accdb")
            Dim cmd As New OleDbCommand
    
            chkCnt = 0
    
            Try
                LstBxPlanBackup.Items.Clear()
                str = "SELECT COUNT(*) FROM Backup"
                cmd.CommandText = str
                cmd.Connection = myConn
                myConn.Open()
                cntPlns = Convert.ToInt32(cmd.ExecuteScalar())
                myConn.Close()
    
                str = "SELECT Nickname, Base, Target FROM Backup"
                cmd.CommandText = str
                cmd.Connection = myConn
                myConn.Open()
                Dim lstReader As OleDbDataReader = cmd.ExecuteReader()
                lstReader.Read()
                Do Until chkCnt = cntPlns
                    LstBxPlanBackup.Items.Add(lstReader.Item(0))
                    chkCnt += 1
                    lstReader.Read()
                Loop
                myConn.Close()
                LstBxPlanBackup.SelectedIndex = 0
            Catch ex As Exception
                myConn.Close()
                LblNickNote1Backup.Text = "Trouble connecting to database to list your plans"
            End Try
    
            LblNickNote1Backup.Text = ""
            LblNickNote2Backup.Text = ""
            LstBxPlanBackup.SelectedItem = TxtBxNickBackup.Text
            MakePlanStr()
        End Sub

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured