Is there a way to center the 'X' icon on the center of the column 'Remover' ? It's placed on the left and i cannot find a way to move it to the center, image of the grid attached. Thanks anyway, any comments about a better way to do this button column are appreciated too. Thanks
3 Answers, 1 is accepted
0
Hello Flames,
Thank you for writing.
To align the image in the middle of the button, you should subscribe to the CellFormatting event of RadGridView and set the ImageAlignment property to "MiddleCenter". For example:
Attached is a demo project that comprises the code above.
I hope this helps. Do not hesitate to write back if you have further questions.
Kind regards,
Anton
the Telerik team
Thank you for writing.
To align the image in the middle of the button, you should subscribe to the CellFormatting event of RadGridView and set the ImageAlignment property to "MiddleCenter". For example:
void
radGridView1_CellFormatting(
object
sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
GridCommandCellElement cmdCell = e.CellElement
as
GridCommandCellElement;
if
(cmdCell !=
null
)
{
cmdCell.CommandButton.ImageAlignment = ContentAlignment.MiddleCenter;
if
(e.Column.Name ==
"column3"
)
{
cmdCell.CommandButton.Image = Properties.Resources._1353922628_home;
}
if
(e.Column.Name ==
"column4"
)
{
cmdCell.CommandButton.Image = Properties.Resources._1353922617_delete;
}
}
}
Attached is a demo project that comprises the code above.
I hope this helps. Do not hesitate to write back if you have further questions.
Kind regards,
Anton
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more.
Check out all of the latest highlights.
0
LEON
Top achievements
Rank 1
answered on 14 Nov 2018, 09:21 PM
this is working fine with C#, but when I convert this to VB its showing error. Trycast block not working for this. is there any workaround for VB.net?
Private
Sub
radGridView1_CellFormatting(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.WinControls.UI.CellFormattingEventArgs)
Dim
cmdCell
As
GridCommandCellElement = TryCast(e.CellElement, GridCommandCellElement)
If
cmdCell IsNot
Nothing
Then
cmdCell.CommandButton.ImageAlignment = ContentAlignment.MiddleCenter
If
e.Column.Name =
"column3"
Then
cmdCell.CommandButton.Image = Properties.Resources._1353922628_home
End
If
If
e.Column.Name =
"column4"
Then
cmdCell.CommandButton.Image = Properties.Resources._1353922617_delete
End
If
End
If
End
Sub
0
Hello, LEON,
You can find below the converted VB.NET code snippet how to center the image for the command cell element:
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
You can find below the converted VB.NET code snippet how to center the image for the command cell element:
Private
Sub
RadGridView1_CellFormatting(sender
As
Object
, e
As
CellFormattingEventArgs)
Dim
cmdCell
As
GridCommandCellElement = TryCast(e.CellElement, GridCommandCellElement)
If
cmdCell IsNot
Nothing
Then
cmdCell.CommandButton.ImageAlignment = ContentAlignment.MiddleCenter
If
e.Column.Name =
"CommandColumn1"
Then
cmdCell.CommandButton.Image = My.Resources.Camera48
End
If
If
e.Column.Name =
"CommandColumn2"
Then
cmdCell.CommandButton.Image = My.Resources.calendar
End
If
End
If
End
Sub
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.