Hello Markus Giera,
RadGridView for Winforms does not support custom hierarchy (yet), but you can achieve similar behavior with the presented API of
RadGridView.
You need to check that a specified row has child rows. Also, as you mentioned you need to subscribe for the
ViewCellFormatting event where you can hide the plus-minus element. Finally you have to prevent from expanding rows that don't have child rows in the
ChildViewExpanding event. You can use the following code snippet:
private
void
radGridView_ViewCellFormatting(
object
sender, CellFormattingEventArgs e)
{
GridGroupExpanderCellElement cellElement = e.CellElement
as
GridGroupExpanderCellElement;
GridViewDataRowInfo dataRow = e.CellElement.RowInfo
as
GridViewDataRowInfo;
if
(cellElement !=
null
&& dataRow !=
null
)
{
bool
hasChildRows =
false
;
if
(dataRow.Tag ==
null
)
{
hasChildRows =
this
.HasChildRows(dataRow);
dataRow.Tag = hasChildRows;
}
else
{
hasChildRows = (
bool
)dataRow.Tag;
}
if
(hasChildRows)
{
cellElement.ResetValue(GridGroupExpanderCellElement.SignStyleProperty, ValueResetFlags.Local);
}
else
{
cellElement.SignStyle = GridGroupExpanderCellElement.SignStyles.Image;
}
}
}
private
void
radGridView_ChildViewExpanding(
object
sender, ChildViewExpandingEventArgs e)
{
GridViewDataRowInfo dataRow = e.ParentRow;
bool
hasChildRows =
false
;
if
(dataRow.Tag ==
null
)
{
hasChildRows =
this
.HasChildRows(dataRow);
}
else
{
hasChildRows = (
bool
)dataRow.Tag;
}
e.Cancel = !hasChildRows;
dataRow.Tag = hasChildRows;
}
If you need further assistance do not hesitate to write us back.
All the best,
Svett
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items.