Divelements Community
Customer discussion of all Divelements products

Sandribbon ComboBox Buttons Vanish

Latest post 04-01-2010 17:53 by Elkay. 4 replies.
  • 01-18-2010 17:07

    • Ryan
    • Not Ranked
    • Joined on 01-18-2010
    • Posts 2

    Sandribbon ComboBox Buttons Vanish

    I've created a very simple windows form using ribbon 1.6.8 with this code:

     

    var b = new GalleryButton("my test button. it's really long and it doesn't show.");

    comboBox1.Items.Add( b );

     

    I just added a ribbon to the form and a single combobox (combobox1) using the designer. If the name is long the button just vanishes. Any help with this would be greatly appreciated.

  • 01-18-2010 17:21 In reply to

    Re: Sandribbon ComboBox Buttons Vanish

    My recollection is that if an item cannot be accommodated in the dropdown, it is culled from the display. You can solve this by making the dropdown from your combobox wider.

  • 01-18-2010 17:24 In reply to

    • Ryan
    • Not Ranked
    • Joined on 01-18-2010
    • Posts 2

    Re: Sandribbon ComboBox Buttons Vanish

    Was there a reasoning for this? It seems very destructive to simply remove an item from the drop down instead of shortening the button graphical display similar to what you do in the actual ComboBox selected field.

  • 01-18-2010 17:31 In reply to

    Re: Sandribbon ComboBox Buttons Vanish

    Popups are not able to grow to accommodate their children, which would be the only acceptable resolution to this. Buttons do not support truncation of their text when displayed, though you're quite right we do this when displaying the text (not the button itself) in the centre of the combo.

  • 04-01-2010 17:53 In reply to

    • Elkay
    • Top 10 Contributor
    • Joined on 08-15-2005
    • Posts 59

    Re: Sandribbon ComboBox Buttons Vanish

    I also ran into this problem but it was a pretty simply solution...here's how I handled it (might be a better way so if anyone has any thoughts, that would be appreciated) and hopefully this Forum will not mess up the indentation too badly!

    Setup:  I have a class that is a collection of my clients called _ClientList and a SandRibbon.ComboBox that will display this list called cmbClient

    cmbClient has a DisplaySize of 200, 19 and a DropDownSize of 200, 200

    Private Sub LoadClients()

       'Clear our Combo
       cmbClient.Items.Clear()

       Dim mySize As Size = cmbProject.DropDownSize
       Dim MaxWidth As Integer = mySize.Width

       ' Populate CLIENT combo box
       Dim Clients As New List(Of Divelements.SandRibbon.GalleryButton)()
       For iCX As Integer = 0 To _ClientList.Count - 1
          Dim ClientName As String = _ClientList.GetDescription(iCX)
          Dim ButtonWidth As Integer = TextWidth(ClientName, cmbClient.Font)
          If ButtonWidth > MaxWidth Then MaxWidth = ButtonWidth

          Dim ClientButton As New Divelements.SandRibbon.GalleryButton(ClientName)
          ClientButton.MinimumSize = New Size(190, 8)
          ClientButton.Enabled = True
          Clients.Add(ClientButton)

          AddHandler ClientButton.Activate, AddressOf ClientButton_Clicked
       Next
       cmbClient.Items.AddRange(Clients.ToArray())
       cmbClient.Enabled = True

       ' Set my dropdown width
       mySize.Width = MaxWidth
       cmbClient.DropDownSize = mySize

    End Sub

    Private Function TextWidth(ByVal myText As String, ByVal myFont As Font) As Integer
      Dim myWidth As Integer = 0
      Dim g As Graphics = Me.CreateGraphics
      Dim mySizeF As SizeF = g.MeasureString(myText, myFont)
      myWidth = CInt(mySizeF.Width)

      g.Dispose()
      g = Nothing
      mySizeF = Nothing

      Return myWidth
    End Function

    Hope this helps,

    -LK

Page 1 of 1 (5 items) | RSS
Copyright © 2008 Divelements Limited
Powered by Community Server (Commercial Edition), by Telligent Systems