Hi, Padan
Youcaneither creating a propertyto pass the row orpassing the row as aparameter in the constructor of the frmEditform. For example,creating a property in the frmEdit form.
Code Snippet partial class Form9 : Form
{
public Form9()
{
InitializeComponent();
}
private DataGridViewRow row;
public DataGridViewRow Row
{
get { return row; }
set { row = value; }
}
private void Form9_Load(object sender, EventArgs e)
{
DataGridViewRow r = row.Clone() as DataGridViewRow;
foreach (DataGridViewCell cell in row.Cells)
{
this.dataGridView1.Columns.Add(cell.OwningColumn.Name,
cell.OwningColumn.HeaderText);
r.Cells[cell.ColumnIndex].Value = cell.Value;
}
this.dataGridView1.Rows.Add(r);
}
}
Then before opening the frmForm, you should assign the current selected rowto the Row propertyof the frmEdit form, something like this
Code Snippet
void button1_Click(object sender, EventArgs e)
{
Form9 f = new Form9();
f.Row = this.dataGridView1.CurrentRow;
f.Show();
}
|