Here I have created sample that show the DataGridView selected value to textbox. I hope this will help you out. If your requirement is different then please let me know in details with example.
Code
DataTable dt;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Country",typeof(string)) });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
dgvDetails.DataSource = dt;
}
private void dgvDetails_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
txtId.Text = dgvDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
txtName.Text = dgvDetails.Rows[e.RowIndex].Cells[1].Value.ToString();
txtCountry.Text = dgvDetails.Rows[e.RowIndex].Cells[2].Value.ToString();
}
Screenshot
