Results 1 to 5 of 5

Thread: ListView Problems

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2004
    Posts
    131

    Question ListView Problems

    I want to have a user select an item/items from a ListView Box, then click an update btn and have the selections appear in a text box. Here is what I got:

    VB Code:
    1. Private Sub btnWhile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWhile.Click
    2.         If lstParts.SelectedItems.Count = 0 Then
    3.             MessageBox.Show("You did not select any items", "Error")
    4.             Exit Sub
    5.         End If
    6.         If lstParts.SelectedItems.Count > 0 Then
    7.             txtLoop.Text = "You have selected: [COLOR=RED]THE ITEMS THAT WERE SELECTED[/COLOR]."
    8.         End If
    9.     End Sub
    Last edited by twisted; Jun 22nd, 2004 at 07:32 AM.
    Twisted

  2. #2
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    Off the top of my head I think SelectedItems is a collection. Just step through the collection and add the values to your string.

    MyListBox.SelectedItems.Item(x)
    Last edited by SeanGrebey; Jun 21st, 2004 at 02:10 PM.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  3. #3
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Did you loose track of the original thread you were posting this in, I posted a completed block of code that does what you want.

    btw, Using the StringBuilder class is recommended by Microsoft over concatenating strings....
    The String object is immutable. Every time you use one of the methods in the System.String class, you create a new string object in memory, which requires a new allocation of space for that new object. In situations where you need to perform repeated modifications to a string, the overhead associated with creating a new String object can be costly. The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object. For example, using the StringBuilder class can boost performance when concatenating many strings together in a loop.
    Last edited by CyberHawke; Jun 21st, 2004 at 03:42 PM.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2004
    Posts
    131
    See my LISTVIEW thread!!!

    Sorry I did lose track of it and made some changes to the question...But I found it now!
    Twisted

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It'd be helpful and useful to you and other guys, who encounter like this problem later, if you mention a descriptive thread title .

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