I have only datagridView in Form1 . What I want is when I select DataGridView Row it will show me Form2 and Displayed their values in TextBoxs of it.
Please, Can somebody have any idea?
Thanks in Advance
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vinay SinghPosted Jun 23, 2016, 5:47 AM
private void dataGridView_SelectionChanged(object sender, EventArgs e)
{
DataGridViewCell cell = null;
foreach (DataGridViewCell selectedCell in dataGridView.SelectedCells)
{
cell = selectedCell;
break;
}
if (cell != null)
{
DataGridViewRow row = cell.OwningRow;
string form1_Id= row.Cells["ID"].Value.ToString();
string form1_Name = row.Cells["Name"].Value.ToString();
Form2 objform2 = new Form2();
objform2.Form2Id= form1_Id;
objform2.Form2Id= form1_Name;
objform2.Show();
}
}
Now on Form2 Page load
public string Form2Id= "";
public string Form2Name= "";
private void Form2_Load(object sender, EventArgs e)
{
txtId.Text = Form2Id;
txtName.Text = Form2Id;
}
Vinay SinghPosted Jun 23, 2016, 12:58 PM
Rose RougePosted Jun 23, 2016, 8:04 AM
Vinay SinghPosted Jun 23, 2016, 8:02 AM
Vinay SinghPosted Jun 23, 2016, 7:36 AM
Rose RougePosted Jun 23, 2016, 7:09 AM
When I click to open Form 1 , it's open Form1 and form2 at the same time and when I select a row, it show me Form2 but with Textboxes empties.
Vinay SinghPosted Jun 23, 2016, 6:24 AM
Rose RougePosted Jun 23, 2016, 6:19 AM
Nirav DaraniyaPosted Jun 23, 2016, 5:44 AM