7 Answers, 1 is accepted
0
Emanuel Varga
Top achievements
Rank 1
answered on 09 Nov 2010, 02:38 PM
Hello,
If you just want to display an image in the column header you can just do the following:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
If you just want to display an image in the column header you can just do the following:
radGridView1.Columns[0].HeaderImage = Properties.Resources.Image;radGridView1.Columns[0].HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleCenter;radGridView1.Columns[0].ImageLayout = ImageLayout.Zoom;radGridView1.Columns[0].TextImageRelation = TextImageRelation.ImageBeforeText;Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0
SURESH
Top achievements
Rank 1
answered on 09 Nov 2010, 02:57 PM
HI
Thanks for your reply
can u tell how to display image on first row only.
Thanks
Suresh.S
Thanks for your reply
can u tell how to display image on first row only.
Thanks
Suresh.S
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 09 Nov 2010, 03:13 PM
Hello again,
Do you want to display the image in the header cell or in the first row?
To display it in the header you can use the code I've posted earlier, for the cells you have to handle the CellFormatting event and add it to the cell there
Best Regards,
Emanuel Varga
Do you want to display the image in the header cell or in the first row?
To display it in the header you can use the code I've posted earlier, for the cells you have to handle the CellFormatting event and add it to the cell there
Best Regards,
Emanuel Varga
0
SURESH
Top achievements
Rank 1
answered on 10 Nov 2010, 07:20 AM
Thanks again
its working .i want to display pop up when i am clicking header image only not in row click .
Regards
suresh.s
its working .i want to display pop up when i am clicking header image only not in row click .
Regards
suresh.s
0
Emanuel Varga
Top achievements
Rank 1
answered on 10 Nov 2010, 09:31 AM
Hello again,
Let me rephrase, if you want to set the image for the First Row cells, then you should use the CellFormatting event and check if RowIndex = 0, and set the image for the Cell, like so:
If you just want to set the Image for the Column header, you can register to the DataBindingComplete event, like this:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Let me rephrase, if you want to set the image for the First Row cells, then you should use the CellFormatting event and check if RowIndex = 0, and set the image for the Cell, like so:
Private Sub RadGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting If (e.CellElement.RowIndex = 0) Then e.CellElement.Image = HeaderCustomImage e.CellElement.ImageAlignment = ContentAlignment.MiddleLeft e.CellElement.ImageLayout = ImageLayout.Zoom e.CellElement.TextImageRelation = TextImageRelation.ImageBeforeText End IfIf you just want to set the Image for the Column header, you can register to the DataBindingComplete event, like this:
Private Sub RadGridView1_DataBindingComplete(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewBindingCompleteEventArgs) Handles RadGridView1.DataBindingComplete RadGridView1.Columns(0).HeaderImage = HeaderCustomImage RadGridView1.Columns(0).ImageLayout = ImageLayout.Zoom RadGridView1.Columns(0).TextImageRelation = TextImageRelation.ImageBeforeTextEnd SubHope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
0
SURESH
Top achievements
Rank 1
answered on 10 Nov 2010, 10:41 AM
hi
i want to display popup when i click that image button from header only .....
thanks
suresh
i want to display popup when i click that image button from header only .....
thanks
suresh
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 10 Nov 2010, 04:50 PM
Hello,
For an image button inside the grid header you will need a custom header element, like so:
And the code for the column:
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
For an image button inside the grid header you will need a custom header element, like so:
Imports SystemImports System.Collections.GenericImports System.TextImports Telerik.WinControls.UIImports Telerik.WinControlsImports System.DrawingImports Telerik.WinControls.EnumerationsImports Telerik.WinControls.PrimitivesPublic Class ImageHeaderCell Inherits GridHeaderCellElement Private m_ImageButton As RadButtonElement Public Property ImageButton() As RadButtonElement Get Return m_ImageButton End Get Set(ByVal value As RadButtonElement) m_ImageButton = value End Set End Property Private m_LabelPrimitive As TextPrimitive Public Property LabelPrimitive() As TextPrimitive Get Return m_LabelPrimitive End Get Set(ByVal value As TextPrimitive) m_LabelPrimitive = value End Set End Property Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(GridHeaderCellElement) End Get End Property Public Sub New(ByVal column As GridViewColumn, ByVal row As GridRowElement) MyBase.New(column, row) column.AllowSort = False m_LabelPrimitive.Text = column.HeaderText column.HeaderText = String.Empty ' Add image to imagebutton here 'm_ImageButton.Image = End Sub Public Overrides Sub Initialize(ByVal column As GridViewColumn, ByVal row As GridRowElement) MyBase.Initialize(column, row) End Sub Protected Overrides Sub DisposeManagedResources() RemoveHandler m_ImageButton.Click, AddressOf imageButton_Click MyBase.DisposeManagedResources() End Sub Protected Overloads Overrides Sub CreateChildElements() MyBase.CreateChildElements() m_ImageButton = New RadButtonElement() m_ImageButton.MinSize = New Size(20, 20) AddHandler m_ImageButton.Click, AddressOf imageButton_Click m_LabelPrimitive = New TextPrimitive Me.Children.Add(m_LabelPrimitive) Me.Children.Add(m_ImageButton) End Sub Protected Overloads Overrides Function ArrangeOverride(ByVal finalSize As SizeF) As SizeF Dim size As SizeF = MyBase.ArrangeOverride(finalSize) Dim rect As RectangleF = GetClientRectangle(finalSize) Me.m_ImageButton.Arrange(New RectangleF(2, finalSize.Height / 2 - m_ImageButton.DesiredSize.Height / 2, m_ImageButton.DesiredSize.Width, m_ImageButton.DesiredSize.Height)) Me.m_LabelPrimitive.Arrange(New RectangleF(m_ImageButton.DesiredSize.Width + 4, finalSize.Height / 2 - m_LabelPrimitive.DesiredSize.Height / 2, finalSize.Width, m_LabelPrimitive.DesiredSize.Height)) Return size End Function Public Overloads Overrides Function IsCompatible(ByVal data As Telerik.WinControls.UI.GridViewColumn, ByVal context As Object) As Boolean Return data.Name = "Select" AndAlso TypeOf context Is GridTableHeaderRowElement AndAlso MyBase.IsCompatible(data, context) End Function Private Sub imageButton_Click(ByVal sender As Object, ByVal e As EventArgs) MessageBox.Show("ImageButton Clicked") End SubEnd ClassAnd the code for the column:
Public Class CustomCheckBoxColumn Inherits GridViewCheckBoxColumn Public Overrides Function GetCellType(ByVal row As GridViewRowInfo) As Type If TypeOf row Is GridViewTableHeaderRowInfo Then Return GetType(ImageHeaderCell) End If Return MyBase.GetCellType(row) End FunctionEnd ClassHope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga