I have a form that contains a few DataGridViews. In the Form's Load event, I create DataTables and bind the DataGridView DataSources to those tables, like so (for example):
newObject.Environment = New DataSet
tblTemps = New DataTable("Temp")
tblTemps.Columns.Add("Date", GetType(Date))
tblTemps.Columns.Add("Temp (F)", GetType(Single))
newObject.Environment.Tables.Add(tblTemps)
dgvTemp.DataSource = newObject.Environment.Tables("Temp")
In design, the DataGridViews have AllowUserToAddRows and AllowUserToDeleteRows set to True. So what I would expect is that when this form loads, dgvTemp will show a grid with the 2 columns and 1 empty 'New' row.
But this is not what is happening - the grids are completely empty. Any ideas why? Any help is greatly appreciated!
Note I set the data source to the tables in that fashion because I want the user to be able to enter data in the grids and have the data tables be updated accordingly.
newObject
is, it is initialized (isnt Nothing). If you encounter an NRE in form load, VS can often swallow the exception. - Ňɏssa PøngjǣrdenlarpDataGridView
will be still empty, then check thatDataGridView.AutoGenerateColumns = true
- Fabio