Is control location relative to visible area of form when form has scroll bar? - vb.net

I have a VB.NET form that dynamically creates a set of controls. If there are too many controls to view on the form, the form will show a scroll bar. (It is an autoscroll form.)
The user can scroll down and click a button which causes the form to change dramatically. It destroys all controls and draws new ones based on user input.
I've noticed that if the user is scrolled to the bottom of the form and click the button, when I destroy and create new controls they aren't located where I want them. It seems to put them relative to the visible portion of the form rather than the top of the top.
Example:
checkbox1.top = 50
checkbox1.left = 15
If the scrollbar is all the way at the bottom, the checkbox should be placed above the visible part of the form. Instead, it is drawn 50 pixels from the top of what I can see.
Please help. How do I make it place the control at an absolute location, rather than being relative to the current position of the scrollbar?

You have to compensate for the scroll position of the container control.
If a panel, then it would look like this:
checkbox1.Top = Panel1.AutoScrollPosition.Y + 50
Alternatively, you could just use a FlowLayoutPanel control, which would handle the placement of the controls for you.

Related

Devexpress Form With Header Panel (Title) and Menu Below Panel

Can someone give me insight how can I achieve the form with panel title first and then menu bar below panel (barmanager). Because devexpress always put barmanager on top
Thank you
EDIT :
After I add standalonebardock, the result as picture shown below: the red bar is standalonebardock
UPDATE :
After I drag the barmanager menu into standalonedock, now it is already inside the dock. But the menu still on top docking, what I need how to make space above menu so I can write title/image/etc
The StandaloneBarDockControl control allows bars to be displayed at any position within the form, not simply docked to the form’s edge. To do this, create a StandaloneBarDockControl object and add bars to it. Bars can be added to the control at design time or runtime.

How to make VB.NET application full screen without moving my controls

I want to make my application so that when it has been maximized the control will automatically position itself it the right place.
Assuming that this is a WinForm project, you need to set the Anchor property of the button to Bottom, Right.
The most useful control is the TableLayoutPanel. You should put all the controls on the panel -> set dock: Full and every time the form resized, the controls stay in their container.

Transparent control or user control in vb.net

I am trying to make a transparent control with child controls that are visible and opaque.
I have added a panel control to the main form via code in the form load event. In this I am adding five buttons as child controls like: panel.controls.add(). To all of these, I have set backcolor=color.transparent.
When I run this program, the button background shows the background of the next button in the panel. If I open a child form, then I can see labels on the child form as the background of the panel.
I want to make container panel control completely transparent, so I can see the main form through it. How can this be achieved?
When the form loads, you can see neighbor buttons behind the actual buttons
"Perform Check" is a label on a child form which I opened right before taking this picture.
: "Check Cases and Combinations" is a button on a child form which I opened right before I took this picture.
How can I make it truly transparent? Why doesn't the background of the panel control refresh with the main form background? The panel sort of "keeps" whatever happens on the main form and shows it as a background.
I found out there some issues with setting controls that are transparent and on top of other controls in the main form. They take the background of the container form, whether or not there is any control in between. I used WPF form instead of the panel and it worked perfectly.

Scroll automatically to a control inside scrollviewer

I have a scrollviewer in page which shows data vertically, and it contains controls like grid, stackpanel and listbox.
Listbox contains items with expanderview. On click of expander view header it expands, I just want that whenever it expands its content get visible in page. Means i have to automatically change scroll position and make visible a Listbox selected control.
Is there any way?
There is a way to manage it Programatically with use of Timer. When the timer is triggerd, we call the timer_Tick event handler, which scrolls to the current index and marks it as selected, and then updates the index. After the last item is highlighted the index is reset to the first item. You can find useful sample here Auto-scrolling ListBox for Windows Phone
You need to calculate the offset where you want to scroll to, and then use ScrollToVerticalOffset(your_offset_value) method.
Have a look over here : How to use ScrollViewer.ScrollToVerticalOffset?

Force Vertical Scrollbar to be Visible in Panel

I have a Windows Forms VB.NET application, with a panel that contains a few other controls.
I set the panel's AutoScroll property to True, and that seems to appropriately apply the scroll bars when they are needed. The issue is that a user must scroll all the way to the right to access the vertical scroll bar. Is there a way to always show the vertical scrollbar no matter where the user is scrolled horizontally?
EDIT
I guess the main problem I have here is that I have a DataGridView inside of a panel. I want the panel to do the vertical scrolling, and not the DataGridView. Why is it when I turn off vertical scrollbars on the datagridview and have autoscroll on the panel, a vertical scroll bar is never shown?
You could add a VScrollBar on the right side of the panel and set code behind to move the panel scroll up and down.
or
A better option may be to switch your panel to a FlowLayoutPanel which provides quite a bit of control over the scroll handles both vertical and horizontal.
Check out MSDN and see how to use all of the properties of the FLP: