Home Forums WinForms controls Other WinForms controls ToolBar Button Alignment

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17888 |

    Is there a way to display a toolbar button right aligned on the toolbar? We have a normal group of buttons on the left side but would like our exit button displayed by itself on the far right.

    Thanks…

    Imported from legacy forums. Posted by Wayde (had 7138 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Wayde,

    What you might want to try is to add the buttons you want on the left, add a SpringPanel SmartItem and then another button which should then be on the far right.

    I hope this helps!

    Imported from legacy forums. Posted by Jenny [Xceed] (had 625 views)

    User (Old forums)
    Member
    Post count: 23064

    That’s a great idea. I guess I didn’t realize I could mix and match items like that.

    Thanks!

    Imported from legacy forums. Posted by Wayde (had 539 views)

    User (Old forums)
    Member
    Post count: 23064

    Hey I tryed that too.
    The spiringtool doesn’t seem to work right when placed in a toolbar. it just won’t expand.

    Imported from legacy forums. Posted by mindloop (had 448 views)

    User (Old forums)
    Member
    Post count: 23064

    I having the same problem. Is this a know bug with springpanel?

    Imported from legacy forums. Posted by taeche (had 568 views)

    User (Old forums)
    Member
    Post count: 23064

    Same issue here.
    Is there any known way to get this working or not?

    Imported from legacy forums. Posted by Chris (had 545 views)

    User (Old forums)
    Member
    Post count: 23064

    Putting a SpringPanel in the toolbar will not spring the button after it to the far right. You may want to send this to technical support so this issue can be fixed in a later release.

    I did however find a temporary fix you can use, though you may need to tinker with it a bit to fit it to your liking.

    In order to make this work, you will need to add a blank (no text & zero width) LabelTool on the toolbar in front of the button you want to push to the far right. The Tool button also needs to be assigned a default width big enough to hold its text string. In my case, I assigned a TextWidth of 50 to the button. Then in your Form SizeChanged event, put some code like the following:

    Private Sub frmMain_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
    Dim width As Integer
    width = Me.Width – RightToolButton.TextWidth – tbStore.Bounds.Right – 20
    If width > 0 Then
    LabelTool2.Show()
    LabelTool2.Width = width
    Else
    LabelTool2.Hide()
    End If
    End Sub

    Basically, what the code I just posted does is this:

    1) Create a temporary variable to hold the width for the LabelTool.
    2) Get your form’s width, then subtract the width of the RightToolButton from it. Then get the right position of the SmartItem that is before the LabelTool on the toolbar and subtract that. In my case, I had a button called ‘tbStore’ in front of the label. Lastly, you need to subtract around 20 or so more pixels from the width to fit the RightToolButton on the same line. This value may be able to be shortened, based on what SmartItem you are trying to put on the far right.
    3) Finally, you make sure the width value is greater than 0 before you assign it to the LabelTool. If it is greater than 0, then you are making the LabelTool visible and assigning it a new width. If it is not greater than 0, then you are hiding the LabelTool, as you won’t need it to push the button.

    If you can think of a better solution let me know, as this is all I could think of. 😉

    Imported from legacy forums. Posted by paulplatter (had 6059 views)

    User (Old forums)
    Member
    Post count: 23064

    Was this issue ever resolved?  I am having the same issue now.

    Imported from legacy forums. Posted by Matt (had 2828 views)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.