Telerik Winforms RadGrid Column Grouping

This article is a code example for how to create this layout in a Winforms Telerik gridview. 

Related Articles

... and you 'll find more on the Telerik Winforms Grid Menu

 

'create the columns. The 'oTelerikGrid' object can be found here
      RadGridView2.Columns.Add(oTelerikGrid.createGridViewTextBoxColumn("Job Task", "JobTask", 11, 50, True, True))
      RadGridView2.Columns.Add(oTelerikGrid.createGridViewTextBoxColumn("User", "CreatedBy", 11, 50, True, True))
      RadGridView2.Columns.Add(oTelerikGrid.createGridViewDateTimeColumn("Date", "Created", True, False))
      'add an image column. we do some of this manually
      Dim oImageColumn As GridViewImageColumn = oTelerikGrid.createGridViewImageColumn("Photo", "ImageBlob", 400, True)
      oImageColumn.ImageLayout = ImageLayout.Zoom
      oImageColumn.AutoSizeMode = BestFitColumnMode.DisplayedCells
      RadGridView2.Columns.Add(oImageColumn)
 
      'columns that are not visible
      RadGridView2.Columns.Add(oTelerikGrid.createGridViewTextBoxColumn("", "RowID", 11, 100, False, True))
 
      'Create two column groups
      'The first one has three rows, one column
      Dim view As New ColumnGroupsViewDefinition()
      view.ColumnGroups.Add(New GridViewColumnGroup("Fields"))
      'supress the 'Fields' header
      view.ColumnGroups(0).ShowHeader = False
      'add three rows
      view.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow())
      view.ColumnGroups(0).Rows(0).ColumnNames.Add("JobTask")
      view.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow())
      view.ColumnGroups(0).Rows(1).ColumnNames.Add("CreatedBy")
      view.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow())
      view.ColumnGroups(0).Rows(2).ColumnNames.Add("Created")
 
      'the second group will have one column, one row, and it will be our image
      view.ColumnGroups.Add(New GridViewColumnGroup("Images"))
      'supress the 'Images' header
      view.ColumnGroups(1).ShowHeader = False
 
      'and our one field
      view.ColumnGroups(1).Rows.Add(New GridViewColumnGroupRow())
      'cause our one row to span all three rows of the other group
      view.ColumnGroups(1).RowSpan = 3
      view.ColumnGroups(1).Rows(0).ColumnNames.Add("ImageBlob")
      RadGridView2.ViewDefinition = view
 
      RadGridView2.EnableGrouping = False
      RadGridView2.AllowAddNewRow = False
      RadGridView2.AllowDeleteRow = False
      RadGridView2.AllowEditRow = False
      RadGridView2.EnableFiltering = False
      RadGridView2.MasterTemplate.EnableSorting = False

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences