The simplest solution is to bind the textbox to the DGV datasource:
string strConnect = SMDBSupport.SMInstanceStorage.GetInstanceConnectionString("Video list");
using (SqlConnection con = new SqlConnection(strConnect))
{
try
{
con.Open();
using (SqlDataAdapter da = new SqlDataAdapter("SELECT Title, ID, Duration, Genre FROM Videos", con))
{
DataTable dt = new DataTable();
da.Fill(dt);
myDataGridView.DataSource = dt;
MyTextBox.DataBindings.Add("Text", dt, "Title");
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
Now when the selection changes, the textbox will be automatically updated.