0

Here's what the form looks like so far

http://i.imgur.com/EoTIZ98.png

  • How would I add the data from the text boxes to the DataGridView as a row?
  • And can I specify where the text from the text goes under what column?
  • If so how? Because the text box order doesn't match the grid on the DataGridView.

My data grid view is called FilesGrid, but the textboxes are the same like textBox1... in order as you see them from top to bottom.

PS: I'm a Noob at C#

1 Answer 1

1

You can use DataGridView.Rows.Add() method like this

FilesGrid.Rows.Add(textBox1.Text, textBox2.Text, textBox3.Text,textBox4.Text);

For further details visit this page

Sign up to request clarification or add additional context in comments.

3 Comments

I get an error...A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll Additional information: Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound. If there is a handler for this exception, the program may be safely continued.
this is because you have attached a datasource to your datagridview remove that and there will be no exception
Please select the answer if it helped your case so that others may benefit from it... Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.