public CargarRolForm(Rol rol) { InitializeComponent(); List<Funcionalidad> funciones = Funcionalidad.getFunciones(); foreach (Funcionalidad f in funciones) { this.checkedListBox1.Items.Insert(f.Id-1, f.Descripcion); } this.checkedListBox1.Refresh(); if (rol != null) { this.rol = rol; this.checkBox1.Checked = rol.Activo; this.descripcion.Text = rol.Descripcion; List<Funcionalidad> funcionalidades = rol.buscarFuncionalidades(rol.Id); foreach (Funcionalidad f in funcionalidades) { this.checkedListBox1.SetItemChecked(f.Id-1, true); } } else { this.checkBox1.Visible = false; } }