Articles in this section
Category / Section

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

1 min read

 

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

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied