To reproduce: use the following code snippet:
public Form1()
{
InitializeComponent();
for (int i = 0; i < 10; i++)
{
this.radDropDownList1.Items.Add("item" + i);
}
this.radDropDownList1.ListElement.AutoSizeItems = true;
this.radDropDownList1.DefaultItemsCountInDropDown = this.radDropDownList1.Items.Count;
radDropDownList1.VisualListItemFormatting += radDropDownList1_VisualListItemFormatting;
}
private void radDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
{
args.VisualItem.Font = new System.Drawing.Font("Segoe UI", 24F,
(((System.Drawing.FontStyle.Bold))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
args.VisualItem.ForeColor = System.Drawing.Color.Navy;
args.VisualItem.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
args.VisualItem.ImageAlignment = ContentAlignment.MiddleCenter;
args.VisualItem.TextImageRelation = TextImageRelation.ImageBeforeText;
args.VisualItem.TextWrap = true;
}
When the pop up is opened, the vertical scroll bar is displayed, although the DefaultItemsCountInDropDown property is set to the Items.Count.
Workaround:
bool flag = false;
SizeF size;
private void radDropDownList1_PopupOpening(object sender, CancelEventArgs e)
{
if (!flag)
{
flag = true;
e.Cancel = true;
this.radDropDownList1.DropDownMinSize = new Size((int)size.Width, (int)size.Height * this.radDropDownList1.Items.Count + 1);
this.radDropDownList1.ShowDropDown();
}
}
private void radDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
{
args.VisualItem.Font = new System.Drawing.Font("Segoe UI", 24F,
(((System.Drawing.FontStyle.Bold))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
args.VisualItem.ForeColor = System.Drawing.Color.Navy;
args.VisualItem.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
args.VisualItem.ImageAlignment = ContentAlignment.MiddleCenter;
args.VisualItem.TextImageRelation = TextImageRelation.ImageBeforeText;
args.VisualItem.TextWrap = true;
if (args.VisualItem.DesiredSize.Height > size.Height)
{
size = args.VisualItem.DesiredSize;
}
}