private int _GetIndexOfItemByKey(int Key) { int RetVal = -1; DataTable dt = (DataTable)chlObjects.DataSource; for (DataRow row in dt.Rows) { if (Convert.ToInt32(row["DataObjectId"]) == Key) { RetVal = dt.Rows.IndexOf(row); break; } } return RetVal; }>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.
>> >>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); >>} >>>>
>>>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"; >>>} >>>>>>
>>>private int _GetIndexOfItemByKey(int Key) >>>{ >>> int RetVal = -1; >>> >>> foreach (what??? Row in chlObjects.Items) >>> { >>> >>> } >>> >>> return RetVal; >>> >>>} >>>