See attached picture.
Hans Heuvelman
6 Answers, 1 is accepted
Thank you for writing.
In order to achieve your requirement, please have a look at the following code snippet:
public
Form1()
{
InitializeComponent();
RadButtonElement exitButton =
new
RadButtonElement();
exitButton.Text =
"Exit"
;
exitButton.MaxSize =
new
System.Drawing.Size(50, 20);
exitButton.Click+=exitButton_Click;
exitButton.Alignment = ContentAlignment.TopRight;
this
.radGridView1.GridViewElement.GroupPanelElement.Children.First().Children.First().Children.Add(exitButton);
}
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
For simplicity I added a StackLayoutPanel to the grouppanel, and by buttons to the StackLayoutPanel.
Should I use the CreateCell event? How do I then recognize when the grouppanel_cell is created?
Thank you for writing back.
I am glad the suggested approach suits your requirement. In order to implement similar functionality in a custom RadGridView, you can create a custom RadGridViewElement and override the CreateGroupPanelElement method. Thus, you can add the desired elements after the GroupPanelElement is created:
public
class
CustomGrid : RadGridView
{
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadGridView).FullName;
}
}
protected
override
RadGridViewElement CreateGridViewElement()
{
return
new
CustomRadGridViewElement();
}
}
public
class
CustomRadGridViewElement : RadGridViewElement
{
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(RadGridViewElement);
}
}
protected
override
GroupPanelElement CreateGroupPanelElement()
{
GroupPanelElement groupPanel =
base
.CreateGroupPanelElement();
RadButtonElement exitButton =
new
RadButtonElement();
exitButton.Text =
"Exit"
;
exitButton.MaxSize =
new
System.Drawing.Size(50, 20);
exitButton.Click += exitButton_Click;
exitButton.Alignment = ContentAlignment.TopRight;
groupPanel.Children.First().Children.First().Children.Add(exitButton);
return
groupPanel;
}
private
void
exitButton_Click(
object
sender, EventArgs e)
{
RadMessageBox.Show(
"Exit"
);
}
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Desislava
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I used similar code in the constructor in 2015Q3 version (see code below), but in the 2017R2 version that breaks on 'rel.Children.Add(stackpanel);'
How do I fix this ?
_lblRecordCount = new RadLabelElement {Text = "Aantal records : " + RowCount, Margin = margin, Font = new Font(_btnStandaardSortering.Font.FontFamily, 10)};
var stackpanel = new StackLayoutPanel {Orientation = Orientation.Horizontal, RightToLeft = true};
stackpanel.Children.Add(_lblRecordCount);
stackpanel.Children.Add(_btnExcel);
stackpanel.Children.Add(_btnPdf);
stackpanel.Children.Add(_btnAdd);
stackpanel.Children.Add(_btnCollapse);
stackpanel.Children.Add(_btnExpand);
stackpanel.Children.Add(_btnStandaardSortering);
var rel = new RadElement();
rel.Alignment = ContentAlignment.TopRight;
rel.Children.Add(stackpanel);
GridViewElement.GroupPanelElement.Children.First().Children.First().Children.Add(rel);
GridViewElement.GroupPanelElement.TextAlignment = ContentAlignment.MiddleLeft;
Thank you for writing.
Here is the modified code snippet applicable for the latest version:
public
class
CustomGrid : RadGridView
{
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadGridView).FullName;
}
}
protected
override
RadGridViewElement CreateGridViewElement()
{
return
new
CustomRadGridViewElement();
}
}
public
class
CustomRadGridViewElement : RadGridViewElement
{
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(RadGridViewElement);
}
}
protected
override
GroupPanelElement CreateGroupPanelElement()
{
GroupPanelElement groupPanel =
base
.CreateGroupPanelElement();
RadButtonElement exitButton =
new
RadButtonElement();
exitButton.Text =
"Exit"
;
exitButton.MaxSize =
new
System.Drawing.Size(50, 20);
exitButton.Click += exitButton_Click;
exitButton.Alignment = ContentAlignment.TopRight;
groupPanel.Children[1].Children.First().Children.Add(exitButton);
return
groupPanel;
}
private
void
exitButton_Click(
object
sender, EventArgs e)
{
RadMessageBox.Show(
"Exit"
);
}
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress