How do I create a right-aligned toolbar button?

Raymond Chen

I didn’t think this was all that common a request, but it came in twice from two different customers, so I guess there are still people creating toolbars, and creating them with right-aligned buttons (even though it violates Windows user interface guidelines, though I can’t find a citation right now). You may have noticed that the toolbar common control doesn’t provide a facility for creating right-aligned buttons. Partly because it’s a violation of the guidelines anyway, but mostly because the default state of every feature is “not implemented.” Adding a feature requires work, and since there is only a finite amount of work available to apply, you have to decide where to spend it. And generally speaking, you don’t focus your efforts on helping people violate the guidelines.

If you want to create a right-aligned toolbar button, you can cobble one together by combining things you already have. I can think of two ways of doing this off the top of my head.

  • Create two toolbars, one for the left-aligned buttons and one for the right-aligned buttons, then size and position them appropriately.
  • Create a separator between the left-aligned buttons and the right-aligned buttons, and set the separator size appropriately.

Which comes to a third reason why there is no feature for right-aligned toolbar buttons: Because you can already do it yourself without too much effort.


Discussion is closed.

Feedback usabilla icon