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?

 

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

Article ID: Published Date: Last Revised Date: Platform: Control:
767 04/30/2011 07/10/2014 WinForms GridDataBoundGrid(Classic)
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

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

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