Show Data from dataGridView in TextBox?
c#
Solution
You'll have to implement the `SelectionChanged` event of your `DataGridView`, then check for whichever row is selected.
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;
idTextBox.Text = row.Cells["ID"].Value.ToString();
nameTextBox.Text = row.Cells["Name"].Value.ToString();
// etc.
}
}
Problem
When i click in row on `dataGridView` i like to populate Textbox with data from that row ? How can i do that ? this data in `dataGridView` (ex. `ID=1, Name=s` ...) to show in `Textbox` Up ??