Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
Multiple bands in win grid
posted

Hello,

I want to have multiple bands in ultrawingrid but all binded to one table. how can i achieve this kind of hierearchy?

  • 53790
    posted

    Hello Rooma,

    Maybe one possible way could be if you are using DataSet,  DataTable and  parent - child relation between two of the columns. For example:

    DataSet ds = new DataSet();

     

    DataTable dt = new DataTable();

    dt.Columns.Add("iIsn", typeof(int));

    dt.Columns.Add("iPIsn", typeof(int));

    dt.Columns.Add("Name", typeof(string));

     

     

    DataRelation dr = new DataRelation("MY", dt.Columns["iIsn"], dt.Columns["iPIsn"],false);

    ds.Relations.Add(dr);

    Using this approach (with self related table) you could met endless loop of hierarchy, so if you want to prevent endless loop of hierachy, you could used MaxBandDepth property. By this way you could set the deep of your hierarchy or other possible approach could be if you hide your root node (for more details please take a look at the attached sample)

    Let me know if you have any questions.

    Regards

     

  • 105
    posted

    If you are looking for a hierarchical structure using  DataTables, you will want to create a DataSet. A DataSet with multiple related DataTables will show up as a multi-banded hierarchical grid. See the code below for an example of how to use a data set. 

    <code>

    //Create a dataset
          var ds = new DataSet("RelationalData");
          //create your data tables
          var dt1 = new DataTable("Parent Band");
          var dt2 = new DataTable("Child Band");
          //add columns to you data tables
          dt1.Columns.Add("PrimaryKey");
          dt2.Columns.Add("ForeignKey");
          dt2.Columns.Add("DataColumn1");
          dt2.Columns.Add("DataColumn2");
          dt2.Columns.Add("DataColumn3");
          //add the data tables to you data set
          ds.Tables.Add(dt1);
          ds.Tables.Add(dt2);
     
          //create a relationship between a column from the parent table and child table
          var parentColumn = dt1.Columns["PrimaryKey"];
          var childColumn = dt2.Columns["ForeignKey"];
          var relationship = ds.Relations.Add(parentColumn, childColumn);
          //bind the data set to the grid
          ultraGrid1.DataSource = ds;

    </code>

    After you load the DataTables with some data, It should look something like this.

  • 610
    Suggested Answer
    Offline posted

    Essentially, you want to use a list within a list. I use the following structure:

    Dim data As New BindingList(Of ParentObject)
    Grid.DataSource = data

    Where ParentObject is defined as...

    Public Class ParentObject
      ...
      Public Property Band2 As New BindingList(Of ChildObject)
      ...
    End Class