No, I want to lop thru all items, checked and unchecked, searching for a key. When the key is found, return it's index position.
>I'm assuming that you want to spin through the Items that have been checked by the user? Maybe not, but I'm not quite clear on what you're wanting to accomplish.
>
>The CheckedListBox.Items is simply a collection of objects.
>The CheckedListBox.CheckedItems is also a collection of objects.
>
>So you'd use object in your foreach. And you can use Items.IndexOf() method to find the index.
>
>
>
>foreach (object item in this.MyCheckedListBox.CheckedItems)
>{
> // I'll let you fill in the blanks (this should give you a nudge)
> int x = this.MyCheckedListBox.Items.IndexOf(item);
>}
>
>
>~~Bonnie
>
>
>
>
>>I'm trying to return the index of an item in a CheckedListBox using the value. The list was bound using:
>>
>>
>>private void _LoadLists()
>>{
>> string ObjectsQuery = "SELECT DataObjectId, AccessTableId, ObjectName FROM DataObject ORDER BY ObjectName";
>> DataSet dsObjects = _ExecuteQuery(ObjectsQuery);
>>
>> chlObjects.DataSource = dsObjects.Tables[0];
>> chlObjects.DisplayMember = "ObjectName";
>> chlObjects.ValueMember = "DataObjectId";
>>}
>>
>>
>>Then, I have this method to get the index, but I'm not sure how to complete it:
>>
>>
>>private int _GetIndexOfItemByKey(int Key)
>>{
>> int RetVal = -1;
>>
>> foreach (what??? Row in chlObjects.Items)
>> {
>>
>> }
>>
>> return RetVal;
>>
>>}
>>
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people