DataGridView Pt.2
Ok. I have a DataGridView object, and I have the SelectionMode property set to FullRowSelect. Ok, so now this lets me to be able to select the rows in the DataGridView object just as I would in a ListBox object. Now what I want to know how to do is, when I select a row in the DataGridView object, for the text within the row to be placed into a textbox. I hope everyone can understand what I am trying to say. It is the same principle with a ListBox and a TextBox. Example:
privatevoid listBox1_SelectedIndexChanged(object sender,EventArgs e)
{
textBox1.Text = listBox1.Text;
}
What this code would do is, once the user selects an item within the ListBox, the text is than placed within a TextBox. I am trying to accomplish the same thing between a DataGridView and a TextBox. Any help would be greatly appreciated for I know I have asked this question in multiple forms. Thank you again.
Try the following. Hook the DataGridView's CurrentCellChanged event and add the following code in the event handler: | | textBox1.Text = dataGridView1.CurrentCell.FormattedValue.ToString(); |
-mark
DataGridView Program Manager
Microsoft
This post is provided "as-is"