Hello!
I have a grid with columns and columngroups, which I declare in XAML. According to the time periods of the data, which should be displayed, I have to change to header of the columngroups.
I tried something like ...
... but the colGrp stays null.
How can I achieve this?
Kind regards
Michael
P.S.: I'm new to WPF!
I have a grid with columns and columngroups, which I declare in XAML. According to the time periods of the data, which should be displayed, I have to change to header of the columngroups.
I tried something like ...
GridViewColumnGroup colGrp = rgvAbsaetze.FindName(
"xcolGrpMon"
+ i)
as
GridViewColumnGroup;
colGrp.Header = aktueller_Monat;
... but the colGrp stays null.
How can I achieve this?
Kind regards
Michael
P.S.: I'm new to WPF!
4 Answers, 1 is accepted
0
Hello,
Kind regards,
Didie
the Telerik team
You can get the GridViewColumnGroup by searching in the ColumnGroups collection of the RadGridView. For example if the name of the group is "Data", then you can find the group using a similar code:
var groups = clubsGrid.ColumnGroups.Where(t => t.Name ==
"Data"
);
Kind regards,
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Michael
Top achievements
Rank 1
answered on 14 May 2012, 04:03 PM
Hello!
I don't no why, but although I can see by debugging the code, that there is a columngroup with the name "colGrpMon1", the code doesn't find it.
I tried ...
... and ...
.... because I thought, that the error lies in the object casting.
What I'm doing wrong?
Bye
Michael
I don't no why, but although I can see by debugging the code, that there is a columngroup with the name "colGrpMon1", the code doesn't find it.
I tried ...
//i starts with 0
var colGrp = rgvAbsaetze.ColumnGroups.Where(t => t.Name == (
"colGrpMon"
+ (i+1)));
GridViewColumnGroup colGrp2 = (GridViewColumnGroup)colGrp;
colGrp2.Header = aktueller_Monat;
... and ...
GridViewGroupColumn colGrp = rgvAbsaetze.ColumnGroups.Where(t => t.Name == (
"colGrpMon"
+ (i+1)))
as
GridViewColumnGroup;
colGrp.Header = aktueller_Monat;
.... because I thought, that the error lies in the object casting.
What I'm doing wrong?
Bye
Michael
0
Hi,
Greetings,
Didie
the Telerik team
Would you please try using the following code:
var groups = clubsGrid.ColumnGroups.Where(t => t.Name ==
"Data"
);
// place the name of your GroupColumn above
if
(groups.ToList().Count > 0)
{
GridViewColumnGroup group = groups.FirstOrDefault();
MessageBox.Show(
"Selected group: "
+ group.Name);
}
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Michael
Top achievements
Rank 1
answered on 16 May 2012, 08:30 AM
Hi Didie!
This code works. Thank you.
Before you post your solution, I iterated the columnsgroups like this, what also worked for me. Perhaps, your solution is a little bit "faster". ;-)
This code works. Thank you.
Before you post your solution, I iterated the columnsgroups like this, what also worked for me. Perhaps, your solution is a little bit "faster". ;-)
foreach
(GridViewColumnGroup item
in
rgvAbsaetze.ColumnGroups)
{
if
(item.Name == Spaltenname)
item.Header = aktueller_Monat;
}