Hello Hassan,
Thank you for this clarification. Please note that unless there is specifically provided version in the forums we do test with the latest one and we do provide replied based on our investigations with the latest vesion.
Indeed, I can confirm that this code does not work with your version. However, with the very next version of the suite (2012.1.12.215) everything works as expected.
To work around the issue in your version you need to create custom visual item as the following one:
public
class
CustomSimpleListViewVisualItem : BaseListViewVisualItem
{
protected
override
SizeF MeasureOverride(SizeF availableSize)
{
if
(
this
.Data ==
null
)
{
return
SizeF.Empty;
}
if
(
this
.dataItem.Owner.ShowCheckBoxes)
{
this
.ToggleElement.Visibility = ElementVisibility.Visible;
}
else
{
this
.ToggleElement.Visibility = ElementVisibility.Collapsed;
}
float
indent = 0;
if
(
this
.Data.Owner.ShowGroups &&
(
this
.Data.Owner.EnableCustomGrouping ||
this
.Data.Owner.EnableGrouping) &&
this
.Data.Owner.Groups.Count > 0)
{
indent =
this
.Data.Owner.GroupIndent;
}
SizeF desiredSize =
base
.MeasureOverride(LayoutUtils.InfinitySize);
desiredSize.Width +=
this
.ToggleElement.DesiredSize.Width;
if
(
this
.Data.Size.Height > 0)
{
desiredSize.Height =
this
.Data.Size.Height;
}
if
(
this
.Data.Size.Width > 0)
{
desiredSize.Width =
this
.Data.Size.Width;
}
RadListViewElement listViewElement =
this
.Data.Owner;
if
(listViewElement !=
null
&& !listViewElement.AllowArbitraryItemWidth)
{
desiredSize.Width = listViewElement.ItemSize.Width;
}
if
(listViewElement !=
null
&& !listViewElement.AllowArbitraryItemHeight)
{
desiredSize.Height = listViewElement.ItemSize.Height;
}
if
(listViewElement !=
null
&& listViewElement.AllowArbitraryItemHeight && !listViewElement.AllowArbitraryItemWidth)
{
SizeF measuredSize =
base
.MeasureOverride(
new
SizeF(desiredSize.Width,
float
.PositiveInfinity));
desiredSize.Height = measuredSize.Height;
}
if
(listViewElement !=
null
&& listViewElement.AllowArbitraryItemWidth && !listViewElement.AllowArbitraryItemHeight)
{
SizeF measuredSize =
base
.MeasureOverride(
new
SizeF(
float
.PositiveInfinity, desiredSize.Height));
desiredSize.Width = measuredSize.Width;
}
if
(listViewElement !=
null
&& listViewElement.FullRowSelect)
{
desiredSize.Width = Math.Max(
float
.IsInfinity(availableSize.Width) ? 0 : GetClientRectangle(availableSize).Width, desiredSize.Width + indent);
}
SizeF clientSize = GetClientRectangle(desiredSize).Size;
RadItem editorElement =
this
.GetEditorElement(Editor);
SizeF sizef =
new
SizeF(clientSize.Width -
this
.ToggleElement.DesiredSize.Width, clientSize.Height);
if
(IsInEditMode && editorElement !=
null
)
{
float
editorWidth = Math.Min(clientSize.Width -
this
.ToggleElement.DesiredSize.Width - indent, availableSize.Width - indent);
editorElement.Measure(
new
SizeF(editorWidth,
float
.PositiveInfinity));
desiredSize.Height = Math.Max(desiredSize.Height, editorElement.DesiredSize.Height);
sizef.Height = desiredSize.Height;
}
this
.layoutManagerPart.Measure(sizef);
//this.Data.ActualSize = desiredSize.ToSize();
PropertyInfo prop =
this
.Data.GetType().GetProperty(
"ActualSize"
);
if
(
null
!= prop && prop.CanWrite)
{
prop.SetValue(
this
.Data, desiredSize.ToSize(),
null
);
}
return
desiredSize;
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(SimpleListViewVisualItem);
}
}
}
To put this item in action, you should use the VisualItemCreating event:
I hope this helps.
Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application.
Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>