how to tranfer Form1 checked GridView Rows Data on Form2 Gridview?
Like This:
how to tranfer Form1 checked GridView Rows Data on Form2 Gridview?
Like This:
There are lot of ways to achieve this. The simplest that comes in my mind is:
-Create an istance of GetDataForm
and call a method which displays the form and get the result:
GetDataForm form2 = new GetDataForm();
List<DataGridViewRow> res = form2.ShowForm();
for (int i = 0; i < res.Count; i++)
mainFormGrid.Rows.Add(res[i]);
-In your GetDataForm
you should have the following method:
bool _closedByTransferButton = false;
public List<DataGridViewRow> ShowForm()
{
ShowDialog();
List<DataGridViewRow> res = new List<DataGridViewRow>();
if(_closedByTransferButton)
{
for(int i = 0;i<grid.Rows.Count;i++)
if((bool)grid.Rows[i].Cells["checkboxColumn"].Value)
res.Add(grid.Rows[i]);
}
return res;
}
-And the Click
event of your Transfer
button should be:
private void tranferButton_Click(object sender, EventArgs e)
{
_closedByTransferButton = true;
Close();
}
Hope this helps.