in my example i have added 2 tabs . in 2nd tab added datagridview and in first tab text box. after tabindex change you will get data in text box. code is given below
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.Columns.Add("col1", "Test");
dataGridView1.Columns.Add("Col2","Result");
string[] newstring=new string[]{"North","333"};
dataGridView1.Rows.Add(newstring);
newstring = new string[] { "East", "444" };
dataGridView1.Rows.Add(newstring);
newstring = new string[] { "Northeast", "555" };
dataGridView1.Rows.Add(newstring);
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (DataGridViewRow dr in dataGridView1.Rows)
{
if (dr.Cells[0].Value != null)
{
if (dr.Cells[0].Value.ToString() == "North")
{
textBox1.Text = dr.Cells[1].Value.ToString();
}
}
}
}
}