Hello All,
I'm a bit of a newbie with Ultragrids(though am very happy with them so far) so I apologize in advance if this is an obvious question....
I am using an UltraGrid to display, update and add information from a database. The user has requested the info be displayed in 2 bands(parent/child). I am displaying the info correctly but am unable to modify any of the settings on the second band (like titles, add filters or add valuelists for combo boxes). I'm assuming it is an issue with the way I have written the code for the actual datarelation:
Dim MainDataTable As New DataTable()
Dim c_dataSet_MaterialsMain = New DataSet()
Dim SecondTableAdapt As New SqlDataAdapter(vw_materialsmain2, CONNSTRING)
MainTableAdapt.Fill(MainTable)
SecondTableAdapt.Fill(SecondDataTable)
UltraGrid1.DataSource = MainTable
c_dataSet_MaterialsMain.Tables.Add(MainTable)
c_dataSet_MaterialsMain.Tables.Add(SecondDataTable)
, MainTable.Columns("materialNumber") _
c_dataSet_MaterialsMain.Relations.Add(SecondaryMaterials)
</code>
Then, this is the code I use to initialize the layout for the grid:
<code>
Call InitializeSubType()
Call InitializeCategory()
Call InitializeMatStatus()
Call InitializeMatType()
band.Override.AllowRowFiltering = DefaultableBoolean.True
band.Override.FilteredInRowAppearance.BackColor = Color.IndianRed
band.Override.FilterClearButtonLocation = FilterClearButtonLocation.Cell
End Sub
This all works great for the parent grid but I'm not having much success with the child band. My teammate suggested using:
but that isn't working and am getting an error when trying to run.
Any help you can provide is much appreciated!
Julie
Julie,
It looks like you're binding the grid to just the main DataTable, especially since you're getting an error when trying to access the second band. Have you tried binding the grid to c_dataSet_MaterialsMain instead?
-Matt
Matt,
Thanks so much for your speedy reply! Just so I'm clear... is it as simple as changing:
to
UltraGrid1.DataSource = c_dataSet_MaterialsMain
I did this and am stil having trouble. Do I need to redefine the data schema in the UltraWinGrid Designer as well.
Sorry, I'm a bit dense today!
Try binding the grid after defining the relation instead of before it, since the InitializeLayout event is fired when you set the DataSource property. Since you don't define the relation until afterwards, you won't have the second band in InitializeLayout.
This did the trick. Thanks again for your help and have a great weekend!