Checkedlistbox, How to access items using index. C#

Discussion in 'C#' started by uzairfarooq, Jan 4, 2009.

  1. #1
    I have a checkedlistbox in my form and want to access name of selected item using index, how to do this. For example I want to access selected item of index 2, how I can do that.
    Please help me, I will be very thankful.
     
    uzairfarooq, Jan 4, 2009 IP
  2. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #2
    if (CheckedListBox1.SelectedIndex == 1) {
    MessageBox.Show(CheckedListBox1.SelectedItem.ToString());
    }
     
    yugolancer, Jan 5, 2009 IP
  3. uzairfarooq

    uzairfarooq Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry, I want to access checkeditems not selecteditems. how to do this?
     
    uzairfarooq, Jan 7, 2009 IP
  4. bibinsmk

    bibinsmk Active Member

    Messages:
    205
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    if (CheckBoxList1.Items[0].Selected == true)
    {
    Response.Write(CheckBoxList1.Items[0].Text);
    }
     
    bibinsmk, Jan 8, 2009 IP