We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GDBG LayoutColumns does not recreate column descriptors

Thread ID:

Created:

Updated:

Platform:

Replies:

94523 May 18,2010 09:38 PM May 25,2010 11:51 PM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 18, 2010 09:38 PM

We are trying to create the code that modifies what columns are visible in GDBG based on the circumstances. To change the layout we use LayoutColumns(string [] {}) method.

It works fine first time (we hide a few columns)
Then when the second time we show some of the previously hidden columns, they appear empty and without column descriptors.

The only workaround we've found was to reapply grid DataSource, or rather recreate GridBoundColumns manually, since we have a lot of columns that are not data bound.

Is there a better way? Recreating columns from scratch is very inconvenient.

We tried this in .NET 1.1 (SF 3.0) and .NET 3.5 (SF 8.1)

Thanks.

DataTable table = new DataTable();
table.Columns.Add("A");
table.Columns.Add("B");
table.Columns.Add("C");
table.Rows.Add(new object [] {"A1", "B1", "C1"});
table.Rows.Add(new object [] {"A2", "B2", "C2"});
table.Rows.Add(new object [] {"A3", "B3", "C3"});

gridDataBoundGrid1.DataSource = table.DefaultView;

Syncfusion.Windows.Forms.Grid.GridHierarchyLevel hl = gridDataBoundGrid1.Binder.GetHierarchyLevel(0);

hl.LayoutColumns(new string[] {"A"});
hl.LayoutColumns(new string[] {"A", "B", "C"});

Christopher Issac Sunder K [Syncfusion]
Replied On May 25, 2010 11:51 PM

Hi Jeck,

Thank you for your interest in Syncfusion products.
Regret for the delay. Please try using GridBoundColumns collection in GridDataBoundGrid to Show/Hide columns instead of LayoutColumns.


GridBoundColumnsCollection coll;
coll = this.gridDataBoundGrid1.Binder.InternalColumns.Clone() as GridBoundColumnsCollection;

//hiding columns
GridBoundColumnsCollection cool = coll.Clone() as GridBoundColumnsCollection;
cool.RemoveAt(2);
cool.RemoveAt(1);
this.gridDataBoundGrid1.GridBoundColumns = cool;

//showing columns
this.gridDataBoundGrid1.GridBoundColumns = coll;


Please refer the following sample which illustrates the above behavior in GridDataBoundGrid.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=MasterDetailHide1705156286.zip

Let me know if you need any further clarifications.

Regards,
Christopher K.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;