How can I work with the Tag property of a winforms checked listbox item?
Posted
by JMSA
on Stack Overflow
See other posts from Stack Overflow
or by JMSA
Published on 2010-05-20T04:22:06Z
Indexed on
2010/05/20
4:30 UTC
Read the original article
Hit count: 231
How can I write a C# winforms code like this?
CheckedListBox items don't have 'Tag' and 'ValueMember' properties.
I know there are many alternatives to this. But I need to work it this way.
private void LoadPermissionsToCheckedListBox()
{
Role selctedRole = (Role)comboBox1.SelectedItem;
int i = 0;
foreach (Permission p in selctedRole.PermissionItems)
{
checkedListBox1.Items.Add(p);
checkedListBox1.Items[i].Tag = p;
}
checkedListBox1.DisplayMember = "PermissionKey";
checkedListBox1.ValueMember = "PermissionID";
}
© Stack Overflow or respective owner