3 Answers, 1 is accepted
0
Thomas
Top achievements
Rank 1
answered on 25 Aug 2014, 07:12 PM
Just figured out a way:
private
void
CalculateSize(RadDropDownList list)
{
float
height = 0;
for
(
int
x = 0; x < list.Items.Count(); x++)
{
height += list.Items[x].MeasuredSize.Height;
}
height += 2;
height = (height > list.DropDownMaxSize.Height) ? list.DropDownMaxSize.Height : (
int
)height;
if
(list.DropDownHeight != height)
{
list.DropDownHeight = (
int
)height;
// Refresh?
list.CloseDropDown();
list.ShowDropDown();
}
}
0
Thomas
Top achievements
Rank 1
answered on 25 Aug 2014, 07:13 PM
Call that function from "PopupOpened" or PopupOpening
0
Hello Thomas,
I can confirm that the PopupOpened/PopupOpening events are suitable for the purpose. Since by this time the drop down height is already set, the "refresh" is needed.
I would also like to mention that while your function will work when the AutoSizeItems = true, for the rest of the cases one can use the following property to retrieve the item's height:
I hope that you find this information useful.
Regards,
Stefan
Telerik
I can confirm that the PopupOpened/PopupOpening events are suitable for the purpose. Since by this time the drop down height is already set, the "refresh" is needed.
I would also like to mention that while your function will work when the AutoSizeItems = true, for the rest of the cases one can use the following property to retrieve the item's height:
radDropDownList1.DropDownListElement.ItemHeight
I hope that you find this information useful.
Regards,
Stefan
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.