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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to hide MainTable/ChildTable's column in a GridDataBoundGrid?

Platform: WinForms |
Control: GridDataBoundGrid(Classic) |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

You can use the GridHierarchyLevel.LayoutColumns method to hide the MainTable/ChildTables columns in a grid. LayoutColumns method rearranges how the columns are displayed in the grid and allows you to specify the covered cells and /or break records into several rows displayed in the grid.

Syntax:

void GridHierarchyLevel.LayoutColumns(String[] mappingNames)

mappingNames:

A string array with field names.

The following string have a specific meaning

  • " - " specifies a covered cell
  • " . " indicated line break inside the record. Subsequent fields will be displayed in another row.
  • "" specifies an empty "whitespace" column.
  • Other than these, you should use the same mapping names that you also use with Syncfusion,Windows.Forms.Grid.GridBoundColumn objects.

C#

void setHiddenCols(GridHierarchyLevel level, int hiddenIndex)

{

 int Colcount = level.InternalColumns.Count;

int hiddenCount = 0;

string[] layout = new string[ Colcount -1 ];

for( int i = 0 ; i< Colcount;i++)

{

 if(i != hiddenIndex - 1)

layout[hiddenCount + i] = level.InternalColumns[i].MappingName;

else

hiddenCount = -1;

}

level.LayoutColumns(layout);

}

VB

 Private Sub setHiddenCols(ByVal level As GridHierarchyLevel, ByVal hiddenIndex As Integer)

Dim Colcount As Integer = level.InternalColumns.Count

Dim hiddenCount As Integer = 0

Dim layout() As String = New String( Colcount -1 ) {}

Dim i As Integer

For i = 0 To Colcount- 1 Step i + 1

If i <> hiddenIndex - 1 Then

layout(hiddenCount + i) = level.InternalColumns(i).MappingName

Else

hiddenCount = -1

End If

Next

level.LayoutColumns(layout)

End Sub

Sample:

http://websamples.syncfusion.com/samples/kb/Grid.Windows/Grid_WF_GDBGHideColumns/main.htm

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon