1
I am programming in C# in Visual Studio 2015, and I have a form with a checkedListBox with names of several courses (The registration is a student).
When marking and saving, it saves the student’s registration in the student table, and introduces me to my datagridview, where it server for viewing
I need now that when I edit the student registration, the checkedListBox appear checked, in the options that were marked at the time of insertion, but I’m not able to do it, I’m using the datagridview itself to perform the update, that is when I click on the cell of the datagridview it opens me another form to make the registration update, I just can’t get the information of my checkedlistbox.
In short:
I need to pull from the bench and mark the Checkedlistbox options that were marked in the student insertion.
This is my code that plays information from my datagridview to my update form.
private void DG_edit_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
Tela_EditarAluno fmr = new Tela_EditarAluno();
fmr.TB_cod.Text = DG_edit.CurrentRow.Cells["Cod"].Value.ToString();
fmr.TB_nome.Text = DG_edit.CurrentRow.Cells["Nome"].Value.ToString();
fmr.TB_idade.Text = DG_edit.CurrentRow.Cells["Idade"].Value.ToString();
fmr.TB_endereco.Text = DG_edit.CurrentRow.Cells["Endereço"].Value.ToString();
fmr.TB_quadra_lote.Text = DG_edit.CurrentRow.Cells["Quadra"].Value.ToString();
fmr.MD_telefoneFixo.Text = DG_edit.CurrentRow.Cells["Residencial"].Value.ToString();
fmr.MD_telefoneCel.Text = DG_edit.CurrentRow.Cells["Celular"].Value.ToString();
fmr.TB_cidade.Text = DG_edit.CurrentRow.Cells["Cidade"].Value.ToString();
fmr.TB_uf.Text = DG_edit.CurrentRow.Cells["Uf"].Value.ToString();
fmr.TB_email.Text = DG_edit.CurrentRow.Cells["Email"].Value.ToString();
fmr.TB_nomepai.Text = DG_edit.CurrentRow.Cells["Pai"].Value.ToString();
fmr.TB_nomemae.Text = DG_edit.CurrentRow.Cells["Mãe"].Value.ToString();
fmr.CB_ativo.Text = DG_edit.CurrentRow.Cells["Ativo"].Value.ToString();
fmr.ShowDialog();
}
I forgot to mention my checkedlistbox, for this reason I took two prints from the initial registration screen and edit screen. insert image description here
this image is from the editing screen.
This is my home screen to register with my checkedlistbox "ACTIVITIES","NOTE: this column is from my student table" I have an Activities column where he plays my STRINGS that were inserted by the checkedlistbox. and when I click on the cell of datagridview on how in the first edit print it has to check and mark the items that were registered in the registration screen.
You said you are not getting popular the listbox with the selected values, where is the routine of recovering the values of BD and popular in the form?
– Denis
Denis good morning. I am using the checkedlistbox, not the listbox, I reformulated my question with the prints, posted the code to take the datagridview information and play in the other form, however I do not know the function to check the items that were registered through the checkedlistbox, and mark them according to what was registered.
– Lucas_Silva