How can I fix location of a child control in form? - winforms

I have a button and I want it to be always at the same location on my form (top-left corner of visible part of the form).
Here is the example:
So when I scroll vertically or horizontally, the button should always be at the top-left corner and it should be visible.
What should I do to make it fixed?

I guess you are using Form's AutoScroll feature.
What about placing Panel with AutoScroll = true on the form and use its scrolling instead? Then you will be able to place a button on a form but over this scrollable panel. So, the scroll rulers will scroll the view panel contents, but the button will stay pinned to the form.
If you don't want to add another container component, then you can add a handler on Scroll event and adjust the button position in response to form scrolling. The ScrollEventArgs argument has ScrollOrientation, NewValue and OldValue to calculate new X/Y position of the control.

On the form, you place a Panel and set: its Dock property to Fill, and AutoScroll property to True.
You place all the other controls inside this panel, but not the button you want to keep visible.
Right-click on the panel->Send-to-Back.
The Panel will adjust the size to match the form; the scrolling will only happen in the panel, so the button will always stay visible(you can set Anchor:Left,Top on it)
In order to be able to scroll(with the mouse wheel), the focus must be on a control inside the scrollable area(inside the Panel), NOT on the button. To prevent the button from getting focus: set TabStop to false on it; also, when it is clicked, you must also set the focus on an other control, by calling:
this.SelectNextControl(the_button, true, true, true, true);

Related

How to scroll an extjs panel towards right

I have an extjs panel. This panel has dynamic contents added into it every time I press a button. This dynamic content gets added to the end of the panel, which is not visible until I do a manual horizontal scroll.
I want to scroll to the right most side everytime a new content is added and user see that content immediately (without manually having to scroll right)
Is there any way, I can automatically horizontally scroll the panel towards the end of the panel in the right
Thx

extjs 4 scroilling WITHOUT a scrollbar

I have this narrow panel which is basically a list of thumbnails, and i need to be able to scroll over them using buttons.
We have a panel (anchor layout), with containers in it, and each container contains the image.
there isn't space for a scrollbar, and anyway we don't want one.
I thought it would be as easy as in the listener for my button calling panel.getEL().scroll('b',20)
but this isn't working because the scrollHeight === ClientHeight so scroll does nothing.
Is there a technique I am missing or should this work?
So you're using a button to scroll through the images? What about having the button's listener remove/hide the containers/images at the front of the panel to allow the others to use the space?

Reset the scrollviewer to its initial position with Silverlight

I have a Silverlight application, containing a scrollviewer in a grid layout.
When I move the scroller down and close this grid with the close button, the scroller remains at the bottom whenever I reopen the grid.
Is there a way I can reset the scroller to the top position?
Hello supriya khamesra,
Please Try this.
Please Put your grid inside scroll viewer and then write your bellow code after grid selection change.
grdDetail.ScrollToVerticalOffset(0d);
OR
grdDetail.ScrollToTop();

EXT Js Panel Resize

I want my ext js panel to be resizable, i.e when I put my mouse over the panel it must show
me the resize controls. How do I do the same ?
Use Ext.Resizable. Check this link:
http://docs.sencha.com/ext-js/4-1/#!/example/resizer/basic.html
Edit: Link updated.
Typically you don't resize the panel component, you resize whatever it is contained within.
If you have the panel in a window object, you resize the window and the panel will resize with it automatically; unless you have specified height/width figures specifically which disables the layout manager from handling it.
resizable: true,
Panels accept a "resizable" attribute that will automatically display Ext.resizer.Resizer handles around the panel.

realign dropdown box after form resize

I have a winform app. On the menu bar, far right, I placed a dropdown box on top of it. When I resize the form the dropdown box obviously stays in the same position (x,y location). How can I get it to move propotionally to the right when the form is resized. It basically stays on the same Y axis.
I can't use a layout control since it's placed on top of the menu.
You can use the Anchor property of the comboBox to do this. Simply set it to Right (probably Top and Right) through the designer.
Or to do it in code:
comboBox1.Anchor = AnchorStyles.Right;

Resources