Question

I'm showing to my users, a list of items within a UltraGrid, that come from database. Now, i'm with one need and I don't find anything useful or any documentation that is clear nor none tutorial is available where I can learn.

I need extend the functionality of this grid, to, set a (+) Expand function, that, when the user press that button (+), the row expands and shows the items that are in the History.

It is anyone in the world that can help me to solve this issue or indicate appropriate docs where I can Learn?

Very thanks.

Was it helpful?

Solution

The trick is simple. You just need to bind the grid to a DataSet that contains two (or more) tables and the correct DataRelation object that glues together the tables.
You need also to be sure that the property grid.DisplayLayout.ViewStyle is set to MultiBand (it is the default so it should be already set).

So, for example, in this pseudocode I load two tables and add them to a dataset, then I define a supposed relation between the columns involved and at last I bind the dataset to the grid.

DataSet ds = new DataSet();
DataTable dtItems = YourLoadDataTableMethodHere("Items");
ds.Tables.Add(dtItems);
DataTable dtHistory = YourLoadDataTableMethodHere("History");
ds.Tables.Add(dtHistory);
DataRelation rel = new DataRelation("Items_History_Relation",
                        dtItems.Columns["IDItem"],
                        dtHistory.Columns["IDItem"]);
ds.Relations.Add(rel);
grid.DataSource = ds;

This will automatically force the UltraGrid to create two Bands (grid.DisplayLayout.Bands[]), in the first Band (Band[0]) you will find the rows of the Items datatable, each row has its [+] button to click and expand the second Band (Band[1]) where you will see the History rows related to the row in the first Band

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top