I have a datagridview that I would like all values on a specific row passed to a new form. I can extract the values, but how would you recommend passing these into the new form (each will be assigned to a specific textbox)?
I would create a class that has a property for each column in your dataset. Then you can use a list of your class to store everything, and each element of the list would be a row. You can then set your DataGridView.DataSource = yourList
. When you need to pass a column along, just pass through that element of the list.
If you really don't need to make a class for your data, you could also just pass a DataGridViewRow to your function.
Most controls are based on the Control base class. That class has the Tag property which can hold user data. Attach the data to the row or cell as needed. I discuss on my blog entitled: C# Winforms and the Hidden Association Tag. HTH
Do you want to hide the rest of the DataGridView from the new form? For instance if you pass a DataGridViewRow to the form the new form can get the values directly. But that would also give them access to the DataGridView.
DataGridViewRow dgr = dataGridView.Rows[0];
MyForm myForm = new MyForm(dgr); // now the form has the Row of information. But it can also access the entire DataGridView as it is available in the DataGridViewRow.
If you want to remove access to the DataGridView then place the values in the row into a container and pass that container. You could use something built in like an ArrayList, List, etc.. or create your own custom container.