C1 ComboBox

Posted by: graham on 23 January 2018, 10:04 pm EST

    • Post Options:
    • Link

    Posted 23 January 2018, 10:04 pm EST

    Does the C1 ComboBox always change the Image to be square?

    Is there some way to have the Image be the same size as it is in the ImageList?

  • Posted 24 January 2018, 12:38 am EST

    Hello Graham,

    The individual images remain to be in square to be accommodated in the C1ComboBox items. The images’ original size cannot be pushed in.

    However, you can adjust the Width and Height with respect to an ImageList using its ImageSize property. This will help the images to take the desired size when the particular item is selected.

    Let us know if you need further assistance.

    Best Regards,

    Esha

  • Posted 24 January 2018, 3:13 am EST

    Thank you for your response Esha.

    Let me please explain where I’m up to and what I’m doing.

    I have an Application that is using C1 Controls extensively.

    In this Application, I wish to have a DropDownCombo that shows Countries with each Country showing it’s Flag, Name and Country Code.

    Now, I have created the Flags in ‘png’ 41,24 Format and that seems good for the ComboBox List. However, the result I get is ridiculous!

    Please see the images below.

    What am I doing wrong?

    Regards, Graham

  • Posted 25 January 2018, 1:10 am EST

    Graham,

    Thanks for the clarity. I am in discussion with the team over the scenario and will get back to you once it is done.

    Best Regards,

    Esha

  • Posted 25 January 2018, 4:39 am EST

    Thank you Esha,

    I’m really perplexed. I have copied the C1ComboBox Control and the VSImageList Control over to a Stub.

    I have renamed the VSImageList Control from imlFlags to ImageList_Flags.

    Now, the Text Property that I have in the C1ComboBox Control in the main Project is ‘LOST’!

    It was, “Select your Country from the DropDown List…”

    Also, when you Click on the C1DropDown List Button, the list shows without Flag Images!

    I have some very real issues with this control. Please advise. Attached is the Stub.

    Regards, Graham.

    .

    C1ComboBox_Stub.zip

  • Posted 29 January 2018, 12:29 am EST

    This C1ComboBox Control is making me dance through hoops!

    And I don’t like it. But, I can’t find another Combo Control That supports images that are not just Square.

    Flags are inherently Rectangular. If I put an Image of a Flag in a ComboBox control that supports Images, I expect that the Image will be Scaled correctly!

    Please get back to me with the solution to this issue.

    For additional information, I am using Windows 10 Build 17083 on a 64bit System and C1 WinForms Controls 4.0.20163.226. You should have that on record, but I repeat it here for clarity.

    If you can give me a secure and non-public space that I can upload the Form to, I would be happy to do so.

    Regards, Graham.

  • Posted 29 January 2018, 5:09 am EST

    Graham,

    Having the images to have the original size in the dropdown is possible. This can be done by following the below mentioned steps:

    1. All images before you add them in the ImageList, should be the same size.

      For example, if you want to use countryimage.png, which is 41x24, other images should be 41x24 too.
    2. Set ImageList.ImageSize to 41x24 too.
    3. For C1ComboBox set:

      3.1 ItemMode = C1.Win.C1Input.ComboItemMode.HtmlPattern;

      3.2 HtmlPattern =

      {0}

    Note, in 3.2 you set the same size in the tag.

    A sample showing the same and using the image that you earlier shared, has been attached.

    If you face the issue of losing text even on using the same method in your original sample, kindly let us know.

    For your information, you can use supportone to submit tickets on a private platform. Kindly login here for the same:

    https://supportone.componentone.com/home

    Best Regards,

    Esha

    ComboBoxImages.zip

  • Posted 1 February 2018, 12:16 am EST

    Hello Esha,

    I have already advised you of the WinForms Version that I have.

    • There is no such Property as MaxDropDownItems in the C1ComboBox Contol I have. Even If I were to try to apply it during the Form Load Event, the Control doesn’t recognise this Property…

    • The Padding Property works fine in the SelectedItem Text Box. What I’m after is the ability to adjust the Gap between the Image and the Country Name in the DropDownList. I think 3 Pixels would be correct. Perhaps that should be done in the HTML Code?

    Graham.

  • Posted 2 February 2018, 3:05 am EST

    Hello Graham,

     1. Apologies for missing on the build version. The MaxDropDownItems property came up in 2017v1 and so, I am afraid it is not present in the build version that you use.
    
     2. The gap between the Image and the Country Name in the DropDownList would indeed be adjusted using the [b]HtmlPattern[/b] property. For this, you may want to use the [b]hspace[/b] attribute of the [b]img[/b] tag as below:
    
    c1ComboBox.HtmlPattern = "<table><tr><td><img src='{0}' width=41 height=24 hspace=3></img></td><td><div style='white-space:nowrap'>{0}</div></td></tr></table>";
    

    Best Regards,

    Esha

  • Posted 2 February 2018, 4:40 am EST

    How ‘Slack’ is all this Support!

    How Slack!

    Graham.

  • Posted 4 February 2018, 11:59 pm EST

    And no Workaround solution!

    I am disappointed in you Grape City!

  • Posted 5 February 2018, 1:16 am EST

    Hello Graham,

    We are sorry that the property does not exist in the builds that you use. We understand that it is not found under your licensed version of the builds and no direct workaround could be shared for the same.

    However, we are discussing with the development team in order to help us with a workaround for you (if possible). We will get back to you as soon as it is done.

    Apologies for the trouble.

    Best Regards,

    Esha

  • Posted 5 February 2018, 5:44 am EST

    Hi Graham,

    Please try the workaround attached. It sets the drop down form size to

    the number of items specified in _maxDropDownItems variable

    Let us know if this helps.

    Regards,

    • Alexey

    ComboBoxImages.zip

  • Posted 5 February 2018, 6:42 am EST

    Thank you for your response.

    It doesn’t work for me.

    I am using VB.Net. Can you please adjust.

    Regards, Graham.

  • Posted 5 February 2018, 10:09 am EST

    Hi Graham,

    I translated this sample to VB.Net.

    Regards,

    • Konstantin

    WindowsApp1.zip

  • Posted 5 February 2018, 10:48 am EST

    Thank you Konstantin.

    But that does not open in my VS Version 2013

    I get errors on every level.

    Regards, Graham.

  • Posted 5 February 2018, 11:00 am EST

    Just give me the Raw Code and I may be able to understand it.

  • Posted 6 February 2018, 12:22 am EST

    Hello Graham,

    The raw code , as from the sample’s translated version is attached.

     ' MaxDropDownItems 
        Private _maxDropDownItems As Integer = 4
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            AddHandler C1ComboBox1.DropDownForm.Open, AddressOf DropDownForm_Open
        End Sub
    
        Private Sub DropDownForm_Open(ByVal sender As Object, ByVal e As EventArgs)
            ' init Height of dropdown form
            Dim height = C1ComboBox1.DropDownForm.Height
            If height > 0 AndAlso C1ComboBox1.Items.Count > 0 Then
                Dim paddings = C1ComboBox1.Style.Padding * 2 + 2
                ' items height
                Dim itemsHeight = height - paddings
                ' item height
                Dim itemHeight = itemsHeight / C1ComboBox1.Items.Count
                ' new items height
                Dim newHeight = Math.Min(_maxDropDownItems, C1ComboBox1.Items.Count) * itemHeight + paddings
                If newHeight < height Then
                    C1ComboBox1.DropDownForm.Size = New Size(C1ComboBox1.DropDownForm.Width, newHeight)
                End If
            End If
        End Sub
    
    

    Let us know if this helps.

    Best Regards,

    Esha

    Form.cs.zip

  • Posted 6 February 2018, 2:43 am EST

    I have translated the Raw Code a little earlier and sent a message to Pragati.

    We are getting very close and if you would consult with him we may get an acceptable ‘Workaround’.

    Regards, Graham.

  • Posted 6 February 2018, 7:11 am EST

    Hello Graham,

    When combobox has many items, the dropdown form uses scrolling. It breaks down the workaround.

    The best possible way to avoid it and get working with a number of items is:

      Private Sub DropDownForm_Open(ByVal sender As Object, ByVal e As EventArgs)
    
            ' init Height of dropdown form
            Dim height =C1ComboBox_Countries.DropDownForm.Height
            If height > 0 AndAlso C1ComboBox_Countries.Items.Count > 0 Then
                Dim paddings = C1ComboBox_Countries.Style.Padding * 2 + 2
                ' item height = image size (24) + padding (top + bottom = 8) + cell border (top + bottom = 2) + (cell spacing = 4)
                Dim itemHeight = ImageList1.ImageSize.Height + 14
                ' new items height
                Dim newHeight = Math.Min(intMaxDropDownItems, C1ComboBox_Countries.Items.Count) * itemHeight + paddings
                If newHeight < height Then
                    C1ComboBox_Countries.DropDownForm.Size = New Size(C1ComboBox_Countries.DropDownForm.Width, newHeight)
                End If
            End If
        End Sub
    
    

    Hope this helps.

    Best Regards,

    Esha

  • Posted 6 February 2018, 9:10 am EST

    Where in the world did ‘ImageList1’ come from, in your code above?

  • Posted 6 February 2018, 9:22 am EST

    I have played with this and I think:-

    Dim itemHeight = ImageList1.ImageSize.Height + 14

    should have been:-

    Dim itemHeight = C1ComboBox_Countries.ItemsImageList.ImageSize.Height + 14

    Now, how close are we getting???

  • Posted 6 February 2018, 9:24 am EST

    My God this is painful!

  • Posted 6 February 2018, 9:49 am EST

    Now, how hard has that been to get this far??

    To a list of 10 Items!

  • Posted 7 February 2018, 12:59 am EST

    Hello Graham,

    Glad that the desired outcome has been achieved. ImageList1 is a collection of images used in the C1ComboBox, as in the VB sample shared earlier.

    Let us know if you need further help.

    Best Regards,

    Esha

  • Posted 8 February 2018, 12:40 am EST

    You read my translation I have given above!

    ImageList1 is WRONG!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels