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
4032
How adding rows to unbound grid
posted

Sorry about this simple question but I'm new to UltraWinGrid. I have a unbound grid and trying to define columns, headers and adding rows from code.

I have placed my code in the initializeLayout event of the grid :

e.Layout.Bands[0].Columns.Add("col1");

e.Layout.Bands[0].Columns.Add("col2");

e.Layout.Bands[0].Columns.Add("col2");

How to add rows ? What I'm expecting is a member of the band-class to craete a new row and the set the values or create a new row, adding cells and adding this new row to the band. But UltraGridRow has no public constructor and the band has no member to generate a row ?

Thanks for any help. Markus

Parents
  • 1590
    posted

     Hello,

    Several ways to do so, the one i use is as follow, just declare a data tabel and bind that table to the grid.

    Sample:

                     DataTable dt = new DataTable();

                     dt.Columns.add("col1");

                     DataRow dr = dt.newRow();

                     dt.Rows.add(dr);

                      this.ultraGrid1.DataSource = dt;

    - This will bind the data table with the grid and an empty single row will also be added in the grid. If you want to add row that already had some values, do the following

                    DataRow dr = dt.newRow();

                    dr["col1"] = "Hello World";

                    dt.Rows.add(dr);

                    this.ultraGrid1.Refresh(); 

     

    - During runtime whenever u want to add new row, just create new row, add it to the data table and refresh ur grid. 

Reply Children