Results 1 to 7 of 7

Thread: display listview data in textbox [RESOLVED]

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    43

    Resolved display listview data in textbox [RESOLVED]

    How do i get a value of my listview to be displayed in a textbox?
    I want to fill my textbox without accessing the database.
    Last edited by Bonkerz; Jun 30th, 2005 at 08:48 PM.

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: display listview data in textbox

    Quote Originally Posted by Bonkerz
    How do i get a value of my listview to be displayed in a textbox?
    I want to fill my textbox without accessing the database.
    Is this what you are looking to do:

    VB Code:
    1. Me.Text1.Text = Me.Listview1.SelectedItem.Text
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    43

    Re: display listview data in textbox

    Sorry should have elaborated on my problem. I want to get values from from the row i selected to 2 textboxes and i need values from 2 columns in the listview.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: display listview data in textbox

    VB Code:
    1. Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    2. Text1.Text = ListView1.SelectedItem.Text
    3. Text2.Text = Item.SubItems(1)
    4. End Sub

  5. #5
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: display listview data in textbox

    Quote Originally Posted by Bonkerz
    Sorry should have elaborated on my problem. I want to get values from from the row i selected to 2 textboxes and i need values from 2 columns in the listview.
    Try this:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim a As Long
    3.  
    4.     With ListView1
    5.         Me.Text1.Item(0).Text = SelectedItem.Text
    6.  
    7.            For a = 1 To .ColumnHeaders.Count - 1
    8.                Me.Text1.Item(a).Text = .SelectedItem.ListSubItems.Item(a).Text
    9.            Next a
    10.  
    11.     End With
    12. End Sub
    Last edited by Mark Gambo; Jun 30th, 2005 at 09:36 AM.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    43

    Re: display listview data in textbox

    Don't really understand why the for next is used in your code Mark, anyway it gave me the value of the 2nd subitem and was good otherwise. Didn't think it was that simple Hack, thanks. Thanks for your help too Mark.

  7. #7
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: display listview data in textbox

    Quote Originally Posted by Bonkerz
    Don't really understand why the for next is used in your code Mark, anyway it gave me the value of the 2nd subitem and was good otherwise. Didn't think it was that simple Hack, thanks. Thanks for your help too Mark.
    The For Next Loop is used to loop through each subitem in the Listview.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


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