I want to edit a record in the "datagridview", and after clicking on a specific record, I need to extract the data from the columns into the filling elements. I don't understand how it can be done with "checkedlistbox". Is it realistic to implement the corresponding creation of marks on "checkedlistbox"? **Would **it be correct to use a for loop to compare elements?
I am trying to do this to edit records with "datagridview".
Clicking on a column:
private void DGV3_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
rowIndex = e.RowIndex;
txtName.Text = DGV3.Rows[e.RowIndex].Cells["name"].Value.ToString();
txtType.Text = DGV3.Rows[e.RowIndex].Cells["type"].Value.ToString();
cmbCoash.SelectedItem = DGV3.Rows[e.RowIndex].Cells["сoach"].Value.ToString();
// try to mark the elements:
dayp = DGV3.Rows[e.RowIndex].Cells["trainingdays"].Value.ToString();
string[] mystring = dayp.Split(',');
foreach (var item in mystring)
{
int i = 0;
foreach (var listItem in chDay.Items)
{
if ((string)listItem == item)
{
chDay.SetItemCheckState(i, CheckState.Checked);
break;
}
}
}
try
{
key = Convert.ToInt32(DGV3.SelectedRows[0].Cells[0].Value.ToString());
}
catch { }
}
}
chDay - checkedlistbox
