checkedlist box problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

checkedlist box problem

havejeethavejeet Posts: 17Member
Hi all,

I have two problems
1. I have a comma separated string values. I want to load them all into checkedlistbox as items.....HOW?

2. how do I get the itemindex of checkedlistbox, passing the text?

regards and thanks
Jeet

Comments

  • PsightoplazmPsightoplazm Posts: 332Member ✭✭
    You can't treat a string byref in .NET unfortunately. The only thing you can do is create a class that holds a string and override the ToString() method.

    Here is how you retrieve an item's index.
    [code]
    var me = new CheckedListBox();
    var s = "This is a string";
    var index = me.Items.Add(s); // you can retrieve when adding
    var altIndex = me.Items.IndexOf(s); // or after the fact.
    [/code]


    ><//~Psightoplasm`~
  • havejeethavejeet Posts: 17Member
    Hi friends,

    it was as simple as it looks!

    arrFieldList = new ArrayList(strAllFields.Split(new char[] { ',' }));

    for (int i = 0; i < arrFieldList.Count; i++)
    {
    checkedlistbox1.Items.Add(arrFieldList[i].ToString());
    }

    regards
    Jeet
Sign In or Register to comment.