G
Guest
Could someone please tell me why couldn't I adjust my column/row properties
of my dataGrid? I binded my table, created a new DataGridTableStyle and
mapped it to my datagrid. However, my columns width wouldn't changed at all.
I am sure this is very easy thing to figure out but I just couldn't see it.
Could you please take a look at my codes. What I am missing? Btw, I got
these codes from MSDN website:
thanks.
.....
Private myDataGrid As DataGrid
Private myDataSet As DataSet
Private TablesAlreadyAdded As Boolean
Private ts1 As New DataGridTableStyle
....
from my default constructor, I rand SetUp()
......
Private Sub SetUp()
'create a dataset with two tables and one relation.
MakeDataSet()
'bind the datagrid to the dataset. the datamember
'specifies that the customers table should be displayed.
myDataGrid.SetDataBinding(myDataSet, "customers")
Dim ts1 As New DataGridTableStyle
ts1.MappingName = "customers"
Dim myDataCol As New DataGridBoolColumn
myDataCol.HeaderText = "My New Column"
myDataCol.MappingName = "current"
myDataCol.Width = 4000000
ts1.GridColumnStyles.Add(myDataCol)
myDataGrid.TableStyles.Add(ts1)
End Sub
.....................along that path, it should execute this dataset then
bind to myDataGrid
Private Sub MakeDataSet()
myDataSet = New DataSet("myDataSet")
Dim tCust As New DataTable("Customers")
Dim cRecordName As New DataColumn("Record Name", GetType(Integer))
Dim cUnitOfMeasurement As New DataColumn("Unit Of Measurement")
Dim cSimulationCaseNo As New DataColumn("Simulation Case Number")
tCust.Columns.Add(cRecordName)
tCust.Columns.Add(cUnitOfMeasurement)
tCust.Columns.Add(cSimulationCaseNo)
myDataSet .Tables.Add(tCust)
Dim newRow1 As DataRow
Dim i As Integer
For i = 1 To 3
newRow1 = tCust.NewRow()
newRow1("Record Name") = i
tCust.Rows.Add(newRow1)
Next i
tCust.Rows(0)("Unit Of Measurement") = "Customer1"
tCust.Rows(1)("Unit Of Measurement") = "Customer2"
tCust.Rows(2)("Unit Of Measurement") = "Customer3"
tCust.Rows(0)("Simulation Case Number") = "asdf"
tCust.Rows(1)("Simulation Case Number") = "asdf"
tCust.Rows(2)("Simulation Case Number") = "asdfdas"
End Sub
of my dataGrid? I binded my table, created a new DataGridTableStyle and
mapped it to my datagrid. However, my columns width wouldn't changed at all.
I am sure this is very easy thing to figure out but I just couldn't see it.
Could you please take a look at my codes. What I am missing? Btw, I got
these codes from MSDN website:
thanks.
.....
Private myDataGrid As DataGrid
Private myDataSet As DataSet
Private TablesAlreadyAdded As Boolean
Private ts1 As New DataGridTableStyle
....
from my default constructor, I rand SetUp()
......
Private Sub SetUp()
'create a dataset with two tables and one relation.
MakeDataSet()
'bind the datagrid to the dataset. the datamember
'specifies that the customers table should be displayed.
myDataGrid.SetDataBinding(myDataSet, "customers")
Dim ts1 As New DataGridTableStyle
ts1.MappingName = "customers"
Dim myDataCol As New DataGridBoolColumn
myDataCol.HeaderText = "My New Column"
myDataCol.MappingName = "current"
myDataCol.Width = 4000000
ts1.GridColumnStyles.Add(myDataCol)
myDataGrid.TableStyles.Add(ts1)
End Sub
.....................along that path, it should execute this dataset then
bind to myDataGrid
Private Sub MakeDataSet()
myDataSet = New DataSet("myDataSet")
Dim tCust As New DataTable("Customers")
Dim cRecordName As New DataColumn("Record Name", GetType(Integer))
Dim cUnitOfMeasurement As New DataColumn("Unit Of Measurement")
Dim cSimulationCaseNo As New DataColumn("Simulation Case Number")
tCust.Columns.Add(cRecordName)
tCust.Columns.Add(cUnitOfMeasurement)
tCust.Columns.Add(cSimulationCaseNo)
myDataSet .Tables.Add(tCust)
Dim newRow1 As DataRow
Dim i As Integer
For i = 1 To 3
newRow1 = tCust.NewRow()
newRow1("Record Name") = i
tCust.Rows.Add(newRow1)
Next i
tCust.Rows(0)("Unit Of Measurement") = "Customer1"
tCust.Rows(1)("Unit Of Measurement") = "Customer2"
tCust.Rows(2)("Unit Of Measurement") = "Customer3"
tCust.Rows(0)("Simulation Case Number") = "asdf"
tCust.Rows(1)("Simulation Case Number") = "asdf"
tCust.Rows(2)("Simulation Case Number") = "asdfdas"
End Sub