private void checkedListBoxControl1_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e) { CheckedListBoxItem currItem = (CheckedListBoxItem)checkedListBoxControl1.GetItem(e.Index); string rolename = (string)currItem.Value; Guid userId = (Guid)this.CurrentUser.标识; //如果选中 if (e.State == CheckState.Checked) { UserInRole uir = new UserInRole(); uir.UserId = userId; uir.Role = rolename; uir.Save(); } //如果没有选中 if (e.State == CheckState.Unchecked) { UserInRole uir = UserInRole.GetUserInRole(userId, rolename); if (uir != null) { uir.Delete(); } } }