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

Column Header Image

6 Answers 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Xavier Soares
Top achievements
Rank 2
Xavier Soares asked on 26 Aug 2008, 09:44 AM
Hello,

Is it possible to add an image to a Column Header instead of Text?

Many Thanks for your previous support/help.

LM

6 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 26 Aug 2008, 02:03 PM
Hi Luis,

Yes, it is possible. Here is some sample code how to achieve this:
GridTableHeaderRowElement header = (this.radGridView1.GridElement as GridTableElement).TableBodyElement.Children[0] as GridTableHeaderRowElement; 
 
            this.radGridView1.ImageList = this.imageList1; 
 
            foreach(RadElement element in header.Children ) 
            { 
                if (element as GridHeaderCellElement != null
                { 
                    (element as GridHeaderCellElement).ImageIndex = 0; 
                } 
            } 
 

1. I create a variable named header and initialize it with the header row element instance.
2. I set an imageList to the gridview which I will use to set images to the headers
3. I iterate through the header cell elements ( i.e column headers ) and then I set images.
4. To change the text of the columns you will have to set the Text property of the header cell elements, too.

If you have any questions please do not hesitate to write me.

Sincerely yours,
Boyko Markov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Xavier Soares
Top achievements
Rank 2
answered on 26 Aug 2008, 04:06 PM
Hi,

I'm sorry but the first line is to much for me! I using vb.net. Can you translate that code to VB.NET?

And in what event should I put that code?

Many Thanks, once more.
LM
0
Xavier Soares
Top achievements
Rank 2
answered on 26 Aug 2008, 05:43 PM
Hi,

nevermind, I  found the solution and is working perfectly!

Thanks
LM
0
Boyko Markov
Telerik team
answered on 28 Aug 2008, 03:01 PM
I'm happy to hear that you found the solution, Luis.

If you have any further questions, do not hesitate to write me back.

 
Regards,
Boyko Markov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ian
Top achievements
Rank 1
Iron
answered on 08 Apr 2021, 10:14 AM

I'm also using VB.net, and your normally excellent code converter can't translate line 1 - maybe you can make these kinds of code (of which there are many in lots of your examples) a little bit simpler, then the code coverter can do it's work.

Maybe a useful step when answering ALL questions - make sure the code converter works on whatever code you sugest?

0
Nadya
Telerik team
answered on 08 Apr 2021, 12:52 PM

Hello, Ian,

If you are trying to convert the code snippet suggested from this reply, here is the same code snippet in VB:

Dim header As GridTableHeaderRowElement = TryCast((TryCast(Me.radGridView1.GridElement, GridTableElement)).TableBodyElement.Children(0), GridTableHeaderRowElement)
    Me.radGridView1.ImageList = Me.imageList1
    For Each element As RadElement In header.Children
        If TryCast(element, GridHeaderCellElement) IsNot Nothing Then
            (TryCast(element, GridHeaderCellElement)).ImageIndex = 0
        End If
    Next

Note, that Telerik Converter works fine when you convert methods instead of separate code snippets.

If you have any other questions please let me know.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Xavier Soares
Top achievements
Rank 2
Answers by
Boyko Markov
Telerik team
Xavier Soares
Top achievements
Rank 2
Ian
Top achievements
Rank 1
Iron
Nadya
Telerik team
Share this question
or