A
Aamir
What is the straightforward way to get the checked contents of a
CheckedListBox.
I have a method that is supposed to return the csv string value out of
CheckedItemCollection. But I don't kow how to access the actual values
when iterating through the collection (value can be either
DisplayMember or ValueMember since this CheckedListBox is populated
from a DataSet table)
In the caller method I call the methid supplying it the CheckedItems
property of the list box:
string strCitiesList = ListToCSV(lstCities.CheckedItems);
//The method definition
private string ListToCSV(CheckedListBox.CheckedItemCollection lst)
{
foreach (Object obj in lst)
{
MessageBox.Show(obj.ToString());
}
}
right now I am only displaying the value, but it shows
"System.Data.DataRowView"
instead of the selected values.
Instead of the "Object" type in the foreach loop I tried to use
"CheckedItemCollection.Item" type but it shows error on compile time.
Any help will be appreciated.
CheckedListBox.
I have a method that is supposed to return the csv string value out of
CheckedItemCollection. But I don't kow how to access the actual values
when iterating through the collection (value can be either
DisplayMember or ValueMember since this CheckedListBox is populated
from a DataSet table)
In the caller method I call the methid supplying it the CheckedItems
property of the list box:
string strCitiesList = ListToCSV(lstCities.CheckedItems);
//The method definition
private string ListToCSV(CheckedListBox.CheckedItemCollection lst)
{
foreach (Object obj in lst)
{
MessageBox.Show(obj.ToString());
}
}
right now I am only displaying the value, but it shows
"System.Data.DataRowView"
instead of the selected values.
Instead of the "Object" type in the foreach loop I tried to use
"CheckedItemCollection.Item" type but it shows error on compile time.
Any help will be appreciated.