6 Answers, 1 is accepted
0
Hello Hans,
Thank you for writing.
You can place a RadButtonElement in the current row's header cell above the row selection arrow by creating a custom GridRowHeaderCellElement. Our GridView >> Creating custom cells help article is quite useful on this topic. Here is a sample code snippet demonstrating the approach for achieving your goal:
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Thank you for writing.
You can place a RadButtonElement in the current row's header cell above the row selection arrow by creating a custom GridRowHeaderCellElement. Our GridView >> Creating custom cells help article is quite useful on this topic. Here is a sample code snippet demonstrating the approach for achieving your goal:
public Form1(){ InitializeComponent(); this.radGridView1.TableElement.RowHeight = 30;}private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e){ if (e.CellType == typeof(GridRowHeaderCellElement)) { e.CellElement = new CustomGridRowHeaderCellElement(e.Column, e.Row); }}public class CustomGridRowHeaderCellElement : GridRowHeaderCellElement{ RadButtonElement btn; LightVisualElement imageElement; public RadButtonElement Button { get { return btn; } } public LightVisualElement ImageElement { get { return this.imageElement; } } public CustomGridRowHeaderCellElement(GridViewColumn column, GridRowElement row) : base(column, row) { } protected override Type ThemeEffectiveType { get { return typeof(GridRowHeaderCellElement); } } protected override void CreateChildElements() { base.CreateChildElements(); this.Children.RemoveAt(0); DockLayoutPanel panel = new DockLayoutPanel(); btn = new RadButtonElement(); btn.MinSize = new Size(15, 10); DockLayoutPanel.SetDock(btn, Telerik.WinControls.Layouts.Dock.Top); panel.Children.Add(btn); imageElement = new LightVisualElement(); imageElement.Margin = new System.Windows.Forms.Padding(0, 0, 0, 2); panel.Children.Add(imageElement); DockLayoutPanel.SetDock(imageElement, Telerik.WinControls.Layouts.Dock.Bottom); this.Children.Add(panel); }}private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e){ CustomGridRowHeaderCellElement cell = e.CellElement as CustomGridRowHeaderCellElement; if (cell != null) { cell.ImageElement.Image = cell.Image; cell.Image = null; if (cell.RowInfo.IsCurrent) { cell.Button.Visibility = Telerik.WinControls.ElementVisibility.Visible; } else { cell.Button.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; } }}I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Hans
Top achievements
Rank 1
answered on 08 Sep 2014, 07:50 AM
Unforunately the buttom appears in the first cell of the datarows in stead of the first headercell left of 'column1'.
![]()
0
Hello Hans,
Thank you for writing back.
On my end the button appears correctly in the row header cell above the arrow image indicating the current row. I have attached my sample project.
If you have any additional questions, please let me know.
Regards,
Desislava
Telerik
Thank you for writing back.
On my end the button appears correctly in the row header cell above the arrow image indicating the current row. I have attached my sample project.
If you have any additional questions, please let me know.
Regards,
Desislava
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
0
Hello Hans,
Thank you for writing back.
The provided picture helped me to understand completely the exact requirement. Please find below the modified sample code demonstrating how to achieve the result from the attached screenshot:
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Desislava
Telerik
Thank you for writing back.
The provided picture helped me to understand completely the exact requirement. Please find below the modified sample code demonstrating how to achieve the result from the attached screenshot:
private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e){ if (e.CellType == typeof(GridTableHeaderCellElement)) { e.CellElement = new CustomGridRowHeaderCellElement(e.Column, e.Row); }}public class CustomGridRowHeaderCellElement : GridTableHeaderCellElement{ RadButtonElement btn; public CustomGridRowHeaderCellElement(GridViewColumn column, GridRowElement row) : base(column, row) { } protected override Type ThemeEffectiveType { get { return typeof(GridTableHeaderCellElement); } } protected override void CreateChildElements() { base.CreateChildElements(); this.Children.RemoveAt(0); btn = new RadButtonElement(); btn.MinSize = new Size(15, 10); this.Children.Add(btn); }}I hope this information helps. If you have any additional questions, please let me know.
Regards,
Desislava
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Hans
Top achievements
Rank 1
answered on 12 Sep 2014, 07:19 AM
This is exactly what I was looking for. Thanks a lot.
