Spoon Yukina
Spoon Yukina

Reputation: 533

Display a gridView row information in another form

I have a GridView in my form (FORM 1), I want when I double click on some record in it to show me all the reocrd informations in another form (FORM 2).

this is the code I use to get a dataRow from the gridView when I double click on it:

 private void gridControl1_DoubleClick(object sender, EventArgs e)
        {
            DataRow row = gridView1.GetDataRow(gridView1.GetSelectedRows()[0]);
        }

But I don't know how can I display the row information in another form (FORM 2).

Form1 : enter image description here

Form2 :

enter image description here

Upvotes: 0

Views: 1523

Answers (2)

Vaclav Svara
Vaclav Svara

Reputation: 359

I dont think so, it is good idea make form constructor parametrized, sometimes it brings troubles

  Form2 frm = new Form2();
  frm.SourceRow = gridView1.GetDataRow(gridView1.GetSelectedRows()[0]);
  frm.Show();

Upvotes: 0

Sjoerd
Sjoerd

Reputation: 75609

Passing Data Between Forms

Basically:

  DataRow row = gridView1.GetDataRow(gridView1.GetSelectedRows()[0]);
  Form2 frm = new Form2(row);
  frm.Show();

Upvotes: 3

Related Questions