Earn Cash from forex trading and free 5$ for Regiatation.

Monday, June 1, 2009

How to move columns



If you want the columns of data in your grid to be in a different order from the order in which it resides in the database, you must manually move the columns.
Additional Information

Open a project that has a grid on it. The "Bind to a DataTable" tutorial is a good place start if you don't have any other projects. Add an ASP button in the design view, and double click it to see the code-behind.

In the button's "click" event add this code:
VB:
UltraWebGrid1.DisplayLayout.Bands(0).Columns(2).Move(0)

C#:
UltraWebGrid1.DisplayLayout.Bands[0].Columns[2].Move(0);

Run the project. Click the button, and a third column will be move to the first column, and the other columns will shift to the right.

Since moving a column bumps all the columns over one, if you are moving muliple columns it is a good idea to start with whichever one you want to appear leftmost. For example:
VB:
UltraWebGrid1.DisplayLayout.Bands(0).Columns.FromKey("SomeColumn").Move(0)
UltraWebGrid1.DisplayLayout.Bands(0).Columns.FromKey("NextColumn").Move(1)
UltraWebGrid1.DisplayLayout.Bands(0).Columns.FromKey("AnotherColumn").Move(2)

C#:
UltraWebGrid1.DisplayLayout.Bands[0].Columns.FromKey("SomeColumn").Move(0);
UltraWebGrid1.DisplayLayout.Bands[0].Columns.FromKey("NextColumn").Move(1);
UltraWebGrid1.DisplayLayout.Bands[0].Columns.FromKey("AnotherColumn").Move(2);

1 comments:

Unknown said...

Hi,In many ways this is true of any design process ,navigation is no way near as sexy as that lovely Web Design Cochin look.Supermarkets have traditionally spent a lot of time getting those aisles lined up so that you buy items you don't really need.Thanks........