Answer the question
In order to leave comments, you need to log in
How to simplify work with datagridview?
Hello.
I have, say, 10 DGV objects. For each of this object, the CellValueChanged event is used, where the same type of procedure is used, in which only the names of the DGV objects are different.
Here's what comes out roughly:
private void dgv_cat_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
NewLineAndUpdate_DB(dgv_cat, " ;cat_name;", "tbl_spr_category");
}
private void dgv_otdel_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
NewLineAndUpdate_DB(dgv_otdel, " ;dep_name;", "tbl_spr_department");
}
...
Answer the question
In order to leave comments, you need to log in
In this case, you can make a wrapper method:
public static void SubscribeToCellValueChanged(this DataGridView dataGridView, string p1, string p2)
{
dataGridView.CellValueChanged += (sender,e) => NewLineAndUpdate_DB((DataGridView)sender, p1, p2);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question