1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Multiline selection in a list box

Discussion in 'C#' started by @kriti, Aug 28, 2010.

  1. @kriti

    @kriti New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    There is 5 items in a List box
    When i click Item1 , textbox1 becomes visible.
    When i click Item2,textbox2 becomes visible.
    and so on.

    This i am able to do
    Code:
    private void lsb_SelectedIndexChanged(object sender, EventArgs e)
            {
                String tempValue;
                foreach (Object obj in lsb.SelectedItems)
                {
                    tempValue = (String)obj;           
                        if (tempValue.ToLower() == "Item1")
                        {
                          textbox1.Visble=true;
                          //Rest texbox are invisible by individually setting textbox2,textbox3,textbox4 visiblity property to false.
                        }
                       else if (tempValue.ToLower() == "Item2")
                        {
                          textbox2.Visble=true;
                          //Rest texbox are invisible by individually setting textbox1,textbox3,textbox4 visiblity property to false.
                        }
                 }
    }
    
    My Question is that,how can i do this
    When I select Item1 and Item2 both,both textbox1,textbox2 should be visible
    or when i click the three Items,corrosponding 3 textboxes should be visible
    I have problem in the code,as When i click Item1 and Item2,tempValue contains Item1 only..
    so it goes to the first loop.
    How can i achieve this multiline selection of items?
     

Share This Page