how to insert values into datagrid, please help me with sample code
Printable View
how to insert values into datagrid, please help me with sample code
You're going to have to provide a much more complete explanation of what you're doing than that. We could guess, but if we guess wrong then you've wasted our time and yours. Please always provide a full and clear description of the problem.
have 10 textbox , 1 datgrid, 1 button control in my form,
after entering values in my all textbox i need to insert that values in my datagrid though button click event
please give me sample code for this
Does the grid contain data already? Where did the data come from? If you're adding data to a database then it would make most sense to use a DataTable bound to both the grid and the TextBoxes.
data grid does not have value already, after giving input in all textbox in need to insert that all values in datagrid
So, the data is NOT going to be saved to a database?
yes you are correct.
In that case, you can do something like this:Obviously you need to specify the correct number of TextBoxes in the correct order for the columns in your grid.vb.net Code:
myDataGridView.Rows.Add(New Object() {Me.TextBox1.Text, Me.TextBox2.Text, Me.TextBox3.Text})
i am getting error as
No row can be added to a DataGridView control that does not have columns. Columns must be added first.
I would hope that that error message would speak for itself.