DropDownHeight

18 posts, 0 answers
  1. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 11 Oct 2010 Link to this post

    Okay, so I have tried setting every property I can find with the word "Height" in it but am still unable to simply specify how tall the drop-down is. Currently I have three items in it, each with an image. When dropped down only 1 item shows and I want all three to be visible. Seems like this should be way more intuitive, like with a property called "DropDownHeight", but it does not exist anymore.

    Any help is appreciated.

    Thanks!
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 11 Oct 2010 Link to this post

    Hi,
    There are two properties manage the number of items in drop down portion of the RadDropDownList.
    If number of items is greater than DefaultItemsCountInDropDown,  Telerik restrict the number of items to DefaultItemsCountInDropDown

    The second property MaxDropDownItems is used for backward compability with the old RadComboBox and also restricts the number of items to MaxDropDownItems. DefaultItemsCountInDropDown cannot be greater than the MaxDropDownItems.

    Please refer to the code snippet below which demonstrates how RadDropDownList calculates the number of items:
    int itemsCount = this.listElement.Items.Count;
                    
    if (itemsCount > defaultItemsCountInDropDown || itemsCount == 0)
    {
        itemsCount = defaultItemsCountInDropDown;
    }
     
    if (itemsCount > this.maxDropDownItems)
    {
        itemsCount = this.maxDropDownItems;
    }

    http://www.telerik.com/help/winforms/telerik.wincontrols.ui-telerik.wincontrols.ui.popupeditorelement-defaultitemscountindropdown.html

    Hope this helps

    Richard

  3. UI for WinForms is Visual Studio 2017 Ready
  4. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2010 Link to this post

    Actually I found a sub-property of the DropDownListElement called DropDownHeight and DropDownMinSize that I was able to use to get my drop-down to be a certain height. Thank you though! I will try this method next time.
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 14 Oct 2010 Link to this post

    Hi agaIn,

    Just curious which verson you are using. The solution that you are using doesn't work for me (I am using the latest version - 2010 Q2 914) whereas the one I provided restricts the number of visible items. Thought I'd ask in case it doesn't work for you if you are not on the latest version and then upgrade to find it no longer works.

    Thanks
    Richard
  6. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 14 Oct 2010 Link to this post

    Hello guys,

    Richard sorry, i have to dissagree on this one, it does work, try this:
    var dropDown = new RadDropDownList();
    this.Controls.Add(dropDown);
    dropDown.BringToFront();
    dropDown.DataSource = new object[]
        { "asd", "asd", "asd", "asd", "asd", "asd", "asd", "asd", "asd", "asd", "asd", "asd", "asd", };
    dropDown.DropDownListElement.DropDownHeight = 20;
    dropDown.DropDownListElement.DropDownMaxSize = new Size(dropDown.Width, 20);

    But this is not the problem, in my opinion the problem with setting a maximum height for a dropdown can cause problems when you are dealing with:
    - custom fonts,
    - custom dpi settings.

    Elements might get cut off and could cause some serious visual glitches on the long run.
    In conclusion, i have to agree with Richard and say that the MaxDropDownItems is the way to go.

    Best Regards,
    Emanuel Varga
  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 14 Oct 2010 Link to this post

    Hi Emanuel,

    Ah, you've put DropDownMaxSize but I took it word-for-word and had added DropDownMinSize as jfkrueger had put in his post which is why it wasn't working for me.
    As we've said though, I think for true compatibility it would be best to use DefaultItemsCountInDropDown (the MaxDropDownItems is there for backward compatibility and I guess will soon be removed)

    All the best
    richard
  8. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 14 Oct 2010 Link to this post

    Hello Richard,

    You know what the strange thing is, that the MaxDropDownItems has priority over the DefaultItemsCountInDropDown... ( i tried it both ways, setting them also in reverse order and the same result)

    dropDown.MaxDropDownItems = 3;
    dropDown.DefaultItemsCountInDropDown = 9;

    And another strange thing is, if you will take a look in metadata, the default value for the MaxDropDownItems is 8 and for the DefaultItemsCountInDropDown is 6, and the number of items shown is 6, so it's fun.

    By the way, the MaxDropDownItems is not deprecated, so it shouldn't be removed, also it sounds more natural to me than the other one....
    We need properties with clearer names if you don't want to spend the entire day telling people which properties to use :).

    Best Regards,
    Emanuel Varga
  9. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2010 Link to this post

    I'm using Q2 2010 SP 2 (10/5/2010) and my original post was correct. Setting the DropDownHeight and DropDownMin size (NOT DropDownMaxSize) to a value (in my case the same value) causes the drop down to be that size. For me, tihs worked perfectly because I knew exactly how many items were in the list and how tall the list needed to be. Furthermore, the only reason I went that way is because every other way i tried does not work. The DefaultItemsCountInDropDown is 6, the MaxDropDownItems is 8 - and it displays the first item and about half of the second when dropped down. Not sure why it wouldn't work for me, simply dragged the RadDropDownList onto the form, added three items with images and text (image is 32x32) and that's all. If it works for other people that's great though, those properties are definitely not as hidden.

    I'll try it in the future, maybe i'll have more luck.

    Thanks again!

  10. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2010 Link to this post

    I'm setting the properties declaratively, although it should not matter. It is just weird that those properties have absolutely no effect for me.
  11. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 14 Oct 2010 Link to this post

    Evening all,

    jfkrueger - If you try this code below, then it doesn't set the height. Whereas if you take Emanuel's example where the DropDownMinSize is replaced with DropDownMaxSize, then it does have the desired effect.
    Dim strings As New System.Collections.Generic.List(Of String)
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    strings.Add("abc")
    Me.RadDropDownList1.DataSource = strings
    RadDropDownList1.DropDownListElement.DropDownHeight = 20
    RadDropDownList1.DropDownListElement.DropDownMinSize = New Size(RadDropDownList1.Width, 20)

    Hi Emanuel - I know. clearer property names would be great and the MaxDropDownItems property does seem more natural. My first code snippet shows how the DropDownList calculates the number of items. I know it's not deprecated but with the introduction of the new DefaultitemsCountInDropDown I imagine it will be soon. Who knows though. It may well be kept.

    Best regards
    Richard
  12. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2010 Link to this post

    In your example the items do not have images and there are more than three, so it's not reflecting my situaion at all. I don't doubt that it does what you say and i'm not arguing, i'm just telling you what is actually happening to me. I've got an app here where what I have specified DOES work and your method doesn't.

    Try my example. Drag one on a form. Add three items. Add an image to each item (32x32) and display imageBeforeText. For ME, when the list drops down it displays the first item and about half of the other item and there is a scroll bar. Stupid when there is only three items in the list. I also have the AutoSizeItems property set to true, otherwise it squishes my images down to the size of the text.

  13. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 14 Oct 2010 Link to this post

    Glad you have it working how you want.
    All the best
    Richard
  14. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2010 Link to this post

    So you're not even going to bother to try and reproduce the issue in the way I actually described? Oh well, who cares about other people this will happen to, right? Interesting approach.

    Have a good one!
  15. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 14 Oct 2010 Link to this post

    I have tried your situation and using a size of 90 I can re-produce a successful resut.
    It would have saved a lot of trouble though and I'm sure you have had a quicker answer if you'd specified that your images were 32x32 at the start. This makes quite a difference.

    Good night
    regards,
    Richard
  16. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2010 Link to this post

    It was in my third post, which was just after I had told you I already found a solution and when emanual started posting and before you both gave me other examples with no images at all. Glad you were finally able to reproduce it.
  17. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 14 Oct 2010 Link to this post

    OK, in my point of view there will always be problems when item formatting is involved.
    Let's consider the following example: you have 5 items, and you want to show 3, from which one has a size of 20, one 30, and one 40, and the rest just 10, what size is the dropdown if you decide to set the minimum displayed items to 3?

    Please guys don't turn this discussion into an argument, we are here to provide solutions (or workarounds) until some problems are fixed.

    In my point of view, this issue does not require a fix, because if you require custom sized items, you should expect treating it like you would any particular case and you can by setting a maximum and a minimum size for the dropdown.

    Best Regards,
    Emanuel Varga
  18. jfkrueger
    jfkrueger avatar
    269 posts
    Member since:
    Jul 2012

    Posted 14 Oct 2010 Link to this post

    Well there really isn't anything to argue about. I disagree that it doesn't need a fix though. If there is a property called MaxDropDownItems, it should work regardless of formatting - otherwise it's just confusing. If the fix is renaming the property I don't care but as it is it's incredibly confusing and I was just lucky enough to stumble upon the properties I did that were buried two levels deep. I agree though, when using custom formatting you should know exactly how tall you need the dropdown and you should actually set the height rather than try to specify the number of items. If you aren't using any custom formatting the MaxDropDownItems is definitely the way to go because as you pointed out earlier if you just set the height of the dropdown you may end up with items getting cut in half.

    Thank you both for participating in this rousing discussion. I think we can put this one to bed but I do think the property names need to be clarified or that it should work regardless of formatting, one or the other.

    Have a great night!
  19. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 15 Oct 2010 Link to this post

    Hi Joe Krueger,

    You can set the DropDownMinSize property to solve this issue. Please consider the following code:


    this
    .radDropDownList1.DropDownMinSize = new Size(0, 500);

    I hope this helps. If you have further questions, I will be glad to help.

    Greetings, Peter
    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready