I have a predefined DataGridView that I need to add rows to from a DataTable without data binding. I am trying to use the DataGridView.Rows.Add() method programmatically however, I do not know the column names of the DataTable. The columns in the DataTable are in the same order as the DataGridView but how do I add them to the DataGridView without knowing the column names?
I have a predefined DataGridView that I need to add rows to from a
Share
Say your DataGridView exists but has no columns. You can do this:
Then add the row data:
Now, if the default textbox column isn’t sufficient, you might have to create a column with a different cell template.