C# Help anyone?

Discussion in 'Gaming' started by White B O I, Apr 5, 2010.

  1. White B O I

    White B O I Well-Known Member

    Age:
    34
    Posts:
    813
    Likes Received:
    0
    Joined:
    Apr 11, 2006
    Location:
    Table Town, Arizona
    I have a listbox, and I have it set so you can select multiple things.

    My problem is, how do I tell Windows it's selecting multiple items?

    Example, a listbox with entries

    1
    2
    3

    Say I select 3 then 1 (in that order)

    Then you press a button, lets name it 'add' for simplicity, then it writes the selected values to lets say... a label. So the label would output 3 1 after you click the button that says add..

    I'm stuck, it's a mental block right now, I know this is easier than I am making it..

    I suppose I could write a foreach loop.. right?

    Code:
    [FONT=Verdana, Arial, Helvetica][SIZE=2]foreach (int i in  IstBox.GetSelectedIndices())  
    {  
        lstBox1.Items[i].Selected = true;  
    }  [/SIZE][/FONT]
    
    I think that may work..

    But I don't know if that's what I want, I only have one listBox, I don't need another! Gah. Unconfuse me please.

    Edit.. Again:

    Alright, I used this to go in the lstBox and find anything selected then delete them.
    Code:
    while (lstTestExpressions.SelectedItems.Count > 0)
                {
                    lstTestExpressions.Items.Remove(lstTestExpressions.SelectedItem);
                }
    Sadly, I cannot use the exact same thing.. I still need to be able to do what I asked above :(
     
    Last edited: Apr 5, 2010

Share This Page