This is a migrated thread and some comments may be shown as answers.

GridViewTemplate displaying an Icon

2 Answers 175 Views
GridView
This is a migrated thread and some comments may be shown as answers.
OD
Top achievements
Rank 1
OD asked on 15 Mar 2017, 01:49 PM

Hello,

I have a radGridView using some childTemplates. I managed to display the title for each tabs (using the template.Caption), but I wanted to know if there is a possibility to display an icon instead of the text.

Also I wanted to have the tabs position on the left (rgvGridVIew1.MasterTemplate.ChildViewTabsPosition = TabPositions.Left), but the caption is then diplayed vertically. Is there a way to show the caption horizontally ?

 See attached image.

Thanks 

2 Answers, 1 is accepted

Sort by
0
OD
Top achievements
Rank 1
answered on 15 Mar 2017, 04:33 PM

I finally managed to find out a solution.

in the RadGridView ViewCellFormatting event :

Dim cellElement As GridDetailViewCellElement = TryCast(e.CellElement, GridDetailViewCellElement)
If cellElement IsNot Nothing Then
 
    Dim el As RadPageViewStripElement = TryCast(cellElement.PageViewElement, RadPageViewStripElement)
    If el IsNot Nothing Then
 
        For Each pageViewItem In cellElement.PageViewElement.Items
            If pageViewItem.Visibility = ElementVisibility.Visible Then
                'Affecting icon
                Select Case pageViewItem.Text
                    Case "PageView1"
                        pageViewItem.Image = My.Resources.icon1
                    Case "PageView2"
                        pageViewItem.Image = My.Resources.icon2
                    Case "PageView3"
                        pageViewItem.Image = My.Resources.icon3
                End Select
                'Deleting PageView text
                pageViewItem.Text = ""
            End If
        Next
 
    End If
 
End If
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Mar 2017, 09:41 AM
Hello Jean-Marc,

Thank you for writing.  

I am glad that you have a suitable solution for assigning an image to the child template's captions. The ViewCellFormatting event is the appropriate way for customizing the child template.

The GridView >> Cells >> Formatting Examples section in the online documentation contains useful code snippets how to customize the grid cells. The following help article demonstrates a approach how to access the GridDetailViewCellElement that holds the child template and apply some styles: http://docs.telerik.com/devtools/winforms/gridview/cells/formating-examples/child-tabs

I hope this information helps. Should you have further questions I would be glad to help.


Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
OD
Top achievements
Rank 1
Answers by
OD
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or