Results 1 to 7 of 7

Thread: [2005]split the selected contents in a listbox?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    47

    Question [2005]split the selected contents in a listbox?

    hi,

    i want the contents of a listbox to appear in separate textboxes... like name, address, number appear in different textboxes when selected...

    is that possible? i hope so!

    thanks
    Last edited by Graycode; Sep 21st, 2006 at 08:47 AM. Reason: did not complete

  2. #2
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005]split the selected contents in a listbox?

    Couple of things,

    1. How are you populating the contents of the listbox?
    2. Is there some sort of separator between the fields in the listbox?

    If you are populating it from a database, you can then query the database based on the row selected to poulate the textboxes.

    If there is some sort of separator, then you can just do a split on the string.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    47

    Re: [2005]split the selected contents in a listbox?

    Quote Originally Posted by bmahler
    Couple of things,

    1. How are you populating the contents of the listbox?
    2. Is there some sort of separator between the fields in the listbox?

    If you are populating it from a database, you can then query the database based on the row selected to poulate the textboxes.

    If there is some sort of separator, then you can just do a split on the string.

    thanks, the contents are called from a db... but could you give me an example of how to query the database based on the row selected?
    much appreciated.
    Last edited by Graycode; Sep 21st, 2006 at 09:34 AM.

  4. #4
    Hyperactive Member
    Join Date
    May 2006
    Posts
    426

    Re: [2005]split the selected contents in a listbox?

    Is it a listbox or a listview!

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    47

    Re: [2005]split the selected contents in a listbox?

    Quote Originally Posted by maps
    Is it a listbox or a listview!

    its a listbox

  6. #6
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005]split the selected contents in a listbox?

    Sure, check out this class, it allows you to set a value for the field, similar to Itemdata in VB6. If you use it you can then store the pk of the row. Then you can just do a query based on the PK.

    to add items to tthe listbox you use
    VB Code:
    1. Me.ListBox.Items.Add(New DataItem("pk","data"))

    then to get the pk back you would use
    VB Code:
    1. Dim intPK as Integer = cType(Me.ListBox.SelectedItem,DataItem).ID

    Now that you would have the PK you can just wirte a query based on the PK

    VB Code:
    1. "SELECT field1,field2 FROM Table WHERE TablePK = " & intPK
    Attached Files Attached Files
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  7. #7

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    47

    Re: [2005]split the selected contents in a listbox?

    Quote Originally Posted by bmahler
    Sure, check out this class, it allows you to set a value for the field, similar to Itemdata in VB6. If you use it you can then store the pk of the row. Then you can just do a query based on the PK.

    to add items to tthe listbox you use
    VB Code:
    1. Me.ListBox.Items.Add(New DataItem("pk","data"))

    then to get the pk back you would use
    VB Code:
    1. Dim intPK as Integer = cType(Me.ListBox.SelectedItem,DataItem).ID
    Now that you would have the PK you can just wirte a query based on the PK


    thanks altho, i have my items already present in tables and have an ID number for each of them... so how would i go around that? would i use
    VB Code:
    1. "SELECT field1,field2 FROM Table WHERE TablePK = " & intPK

    does this split the line of the selected item and put each value in separate boxes??

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