public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
dataGridView1.Rows.Add( 1,2);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == -1 )
{
try
{
Form2 f2 = new Form2();
f2.dgvr = dataGridView1.Rows[e.RowIndex];
f2.Show();
}
catch (Exception er)
{
MessageBox.Show(er.Message.ToString());
}
}
}
}
public partial class Form2 : Form
{
public DataGridViewRow dgvr;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = dgvr.Cells[0].Value.ToString();
textBox2.Text = dgvr.Cells[1].Value.ToString();
}
}