B
bob
I am binding a datatable to a datagrid in VB.NET I then want to change
the width of the first column. I am unable to get the right syntax.
Here is the code I tried
Dim mydataset As DataSet
gclodatabase.GetDataSetJobs("Select * from qryJobs",
mydataset)
Dim Mydatatable As DataTable = mydataset.Tables(0)
dtgSelect.DataSource = mydataset.Tables(0)
dtgSelect.TableStyles(0).GridColumnStyles("JobId").Width = 10
‘ this fails with an error An unhandled exception of type
'System.NullReferenceException' occurred in Proposals.exe
‘Additional information: Object reference not set to an instance of an
‘object.
dtgSelect.TableStyles(0).GridColumnStyles(1).Width = 10
‘ this fails with error
‘An unhandled exception of type 'System.ArgumentOutOfRangeException'
‘occurred in mscorlib.dll
‘Additional information: Index was out of range. Must be non-negative
‘and less than the size of the collection.
dtgSelect.Refresh()
the width of the first column. I am unable to get the right syntax.
Here is the code I tried
Dim mydataset As DataSet
gclodatabase.GetDataSetJobs("Select * from qryJobs",
mydataset)
Dim Mydatatable As DataTable = mydataset.Tables(0)
dtgSelect.DataSource = mydataset.Tables(0)
dtgSelect.TableStyles(0).GridColumnStyles("JobId").Width = 10
‘ this fails with an error An unhandled exception of type
'System.NullReferenceException' occurred in Proposals.exe
‘Additional information: Object reference not set to an instance of an
‘object.
dtgSelect.TableStyles(0).GridColumnStyles(1).Width = 10
‘ this fails with error
‘An unhandled exception of type 'System.ArgumentOutOfRangeException'
‘occurred in mscorlib.dll
‘Additional information: Index was out of range. Must be non-negative
‘and less than the size of the collection.
dtgSelect.Refresh()