I have a linq Query that I have bound to a Checkbox list using Windows forms
var webresourcesFromCRM = (from w in orgSvcContext.CreateQuery("webresource")
select new
{
webresourceid = w["webresourceid"],
name = w["name"]
}).ToList();
I have used the DisplayMember and ValueMember properties when binding
cblWebResources.DataSource = webresourcesFromCRM;
cblWebResources.DisplayMember = "name";
cblWebResources.ValueMember = "webresourceid";
the above code works great. However My problem is I want to get the ValueMember of the checked items. I've tried every combination of cblWebResources.SelectedItems or cblWebResources.SelectedIndices. I just want to be able to loop through my selected items and out put each ValueMember in a windows form app.
I've try other posts like but no luck this is a windows form app
var selectedItems = checkedUsers.Items.Cast<ListItem>()
.Where(li => li.Selected)
.Select(li => int.Parse(li.Text));
int sum = selectedItems.Sum();
string items = string.Join(",", selectedItems);
Aucun commentaire:
Enregistrer un commentaire