Setting the Maximum Height and Maximum Width of the Drop-Down List

You can specify the maximum height and maximum width of a combo box's drop-down list by setting its MaxDropDownHeight and MaxDropDownWidth properties. This topic assumes that the DropDownHeight and DropDownWidth properties are both set to NaN. For more information, see Drop-Down List Sizing.

In the Designer

Complete the following steps:

1.   Click the C1ComboBox control once to select it.

2.   In the Properties window, complete the following:

      Set the MaxDropDownHeight to a value, such as "150".

      Set the MaxDropDownWidth to a value, such as "350".

3.   Run the program and click the combo box's drop-down arrow to see the result of your settings.

In XAML

Complete the following steps:

1.   Add MaxDropDownHeight="150" and MaxDropDownWidth="350" to the <c1:C1ComboBox> tag so that the markup resembles the following:

 

<c1:C1ComboBox HorizontalAlignment="Left" Width="249" MaxDropDownHeight="150" MaxDropDownWidth="350">

 

2.   Run the program and click the combo box's drop-down arrow to see the result of your settings.

In Code

Complete the following steps:

1.   Open the MainPage.xaml.cs page.

2.   Add the following code beneath the InitializeComponent() method to set the DropDownHeight property :

      Visual Basic

      C#

3.   Add the following code beneath the InitializeComponent() method to set the DropDownWidth property :

      Visual Basic

      C#

4.   Run the program and click the combo box's drop-down arrow to see the result of your settings.

 This Topic Illustrates the Following:

In this topic, you set the MaxDropDownWidth property to a value of 350 pixels and the MaxDropDownHeight property to a value of 150 pixels. With these settings, the width of the drop-down list will never be more than 350 pixels and the height will never be more than 150 pixels; however, the height and width can be less than 150 pixels by 350 pixels that if the items in the list aren't enough to fill that area.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.