Answer the question
In order to leave comments, you need to log in
How to make a request to an object of another form?
In the first form, I open the second one like this:
addgroup form = new addgroup();
form.Owner = this;
form.ShowDialog();
public void button1_Click(object sender, EventArgs e)
{
int val_id = this.Owner.dataGridView1.Rows.Count + 1;
}
Answer the question
In order to leave comments, you need to log in
make a new constructor in the addgroup form that will take dataGridView as an input and store it as a field.
when creating, pass your grid to a new form and use
private DataGridView maingrid there;
public addgroup(DataGridView grid)
{
maingrid=grid;
}
addgroup form = new addgroup(dataGridView1);
form.Owner = this;
form.ShowDialog();
public void button1_Click(object sender, EventArgs e)
{
int val_id = maingrid.Rows.Count + 1;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question