Keep WinForms buttons centered automatically - winforms

I have a form with several buttons that I hide and show as needed. Is there a simple way to keep the visible buttons centered, side by side (maybe using one of the container controls)?

Turning off the anchor in a direction and setting dock to none will keep the control centered
Hope, this is what you need...!!

Related

Codenameone list scrollbar quetions

I have a list and its scroll bar on the right along with two custom buttons representing upscroll and downscroll. These two buttons simulate scrolling by using list.setSelectedIndex(index, true) and are placed above and below my scrollbar via my custom layout.
I have two questions regarding this:
1). Since the upscroll and downscroll buttons are overlayed on top of the list, they disappear when i click elsewhere..and they kind of flash into appearance when i click the area it's supposed to be in. How can I remedy this behavior?
2). I have a scrollbar image that I have used in the "Scroll" theme in the GUI builder. It's alignment is IMAGE_ALIGNED_CENTER. However the scroll thumb doesn't reach the end of the bar when i scroll to the end of the list via my upscroll and downscroll buttons. The upscroll and downscroll buttons essentially scroll the list by one index with each press (using setSelectedIndex(index, true)).
Thanks
How do you overlay the buttons. I'm assuming you just set them into a specific location which disallowed as we can't possibly adapt them to the various resolutions. I suggest reading the developer guide section on layouts very carefully.
To place something on top of the list in a portable way you need to use the LayeredLayout or the LayeredPane and a Container + correct layout to position this within (e.g. BorderLayout EAST).
In this blog post there is a sample for making a scrollbar but it isn't "on top". It can be used as a starting point.

Disable the "hover" scrolling effect of a scrolling menu and use a vertical scrollbar instead

How can I disable the default scrolling effect of a menu and just use a vertical scrollbar. I am able to use the scrollbar when I set overflowY to 'auto'. However, the mouse scroll wheel doesn't work as expected anymore, and the behavior in general is just wonky. I suspect it is because both scrolling is in effect and they are comflicting with each other.
I'm not sure if there is a config option that I am missing. The weird behavior can be seen here: Fiddle
Have you tried setting a height / maxHeight on the menu and setting overflowY:'scroll' ?
I'm working around this issue by simply embedding a panel with a fixed size as a menu item, and then adding all the components to the panel instead. This gives me a lot more flexibility to layout the items, and not have to worry about the inconsistent scrolling of an overflown menu.

Windows forms app, autoscale controls with form

I'm a newbie. Designing a form that can be resized, and I want my textboxes, labels and buttons to resize with the form, can someone tell me how to do this?
It depends on the type of layout you need. The "basic tools" you have to do that are following properties: Anchor and Dock.
Anchor
With the Anchor property you "attach" a side of an element to a side of its container. For example if you place a button in the bottom-right corner of a window and you set "Bottom, Right" as Anchor then when you'll resize the form the button will keep its relative position to that corner.
Now imagine you place a multiline text-box in the form, resize as needed (for example 4 px from top, left and right border and 128 px height) and set the Anchor property to "Left, Top, Right". When you'll resize the form that control will keep its height but it'll resize to keep its margins (so if you'll make the form wider its width will be increased).
Dock
Dock is different. With docking you "say" to the Layout Manager to use all available space in one direction. For example if you set to Left then your control will keep its width but it'll use all the available height and its location will be most left as possible.
You may have more than one control docked in a container, imagine you have 5 textbox with Top docking inside a form. They'll be stacked to the top of the form using all the width (and resizing). Another example: a Top docked control (as a banner) and a "Fill" docked control (as main content). Remember that with docking the order of controls matters (if you first place the "Fill" control it'll use ALL the available space and the "Top" dock control will overlap).
Even more
Moreover you have some layout controls too (tables and stacks). They're really easy to use and a 30 minutes of "experiments" will clarify much better than a long text.

How can I center a tooltip above my control in Silverlight?

I want to be able to display a tooltip centered above my control.
I know how to customize the XAML used to display the tooltip using the TooltipService, however, the placement options the TooltipService makes available only allow you to specify top, bottom, left, right, etc. They don't let you specify an alignment once on the given side.
By simply using the TooltipService, selecting a placement of "Top" puts the tooltip above the control and has it aligned to the left side of the control. If there is not enough room for it to be aligned left, it moves it to be aligned on the right side of the control.
I want the tooltip to be centered on the top of the control. I don't want it to anchor to either the left or the right while on top.
Is this possible? How?
you should check out the TooltipService. MSDN documentation is here. and here is a (WPF) sample from CodeProject.
A quick shot: you could create your own TooltipService class to extend the possibilities of the existing one to manipulate a Tooltip instance.
Here you can find a nice class to help position a popup by specifying a list of preferred positions, like the TooltipService does for tooltip. You can specify a Top placement with Center HorizontalAlignment. I know this isn't a tooltip but I thought you could check it out and use it to create a BetterTooltipService.

Auto-size controls in .NET CF to avoid horizontal scrolling?

I am developing a form in .NET Compact Framework, which hosts a variable number of controls. Every control should have the same width as the form. When there are only a few controls, no vertical scrollbar appears. When there are more controls than they can fit in one form, a vertical scrollbar appears. The width of the controls should then be modified, so that no horizontal scrollbar appears.
What is the best way to achieve this? I am interested in a solution that will work in all platforms/screen sizes and that can support screen orientation changes.
If I get this right, at one point, both a vertical and horizontal scrollbar appear, and you want only the vertical scrollbar? Doesn't setting the Anchor of each control to "Top|Left|Right" solve this problem automatically?
If every control is to be the same width as the form, why not just Dock every control to Top (or Bottom)? It'll take care of the resizing for you then. It might not look very attractive however, so I suggest adding in some empty Panels (docked the same way) to be used as vertical spacers.
I did some quick testing, and it seems, when you add controls, the panel raises the resize event when the added control tiggers the scollbars to go visible. The annoying part is here that the resize event is triggered a couple of times during startup :(
But knowing the compact framework, this might be your best shot at handling this.
Normally on the full framework you could if the DisplayRectangle is bigger than the size of the panel, but no such thing exists on the cf.
Hope this is of some help, I'll see if I can find anything more in the morning.

Resources