Я хочу добавить сохраненный CustomDataGridViewRow
в DataGridView
, который связан.Например:
CustomDataGridViewRow rowTemplate = new CustomDataGridViewRow();
dataGridView1.RowTemplate = rowTemplate;
Datenbank.cmd =
new SqlCommand("[Terminauswertung_Bericht_Gesamt]", Datenbank.connection);
Datenbank.cmd.CommandType = CommandType.StoredProcedure;
Datenbank.cmd.Parameters.AddWithValue("@berichtsnr", 1);
SqlDataAdapter adapter = new SqlDataAdapter(Datenbank.cmd);
dataSet1.Tables.Clear();
adapter.Fill(dataSet1, "Table");
bs = new BindingSource();
bs.DataSource = dataSet1.Tables["Table"];
dataGridView1.DataSource = bs;
Мысль идет так:
dataSet1.Tables[0].Rows.Add(Cache.getRow(1));
public class cache
{
Dictionary<int, CustomDataGridViewRow> _cache =
new Dictionary<int, CustomDataGridViewRow>();
public CustomDataGridViewRow getRow(int index)
{
foreach (KeyValuePair<int, CustomDataGridViewRow> dic in _cache)
{
if (dic.Key == index)
return (dic.Value);
}
return (new CustomDataGridViewRow());
}
}
Но он показывает мне только DataGridViewRow {Index = 1} в первой ячейке.