Attach button to panel - c#

I created a simple Winform application with a panel and a button on it. when move panel, the button doesn't. Is it possible to attach button to panel so each operation on panel implies operation on button too?

You will want to go to the panel's properties page, find the property “dock” and set it to the option that best suits your needs, probably “fill”. Whatever you do to the panel, will also manage changes to controls docked to the panel.

Related

why are new controls showing up in my form AND panel

i have a form with a few controls on it, i have a panel with different controls on, That panel is above the form controls.
i have added new controls to the form and when i place the panel back over the form, the new controls are showing through the panel itself, but only the new one controls and not the "old" ones, if i copy and paste a control or add a new one it has the same effect.
i have looked in the designer.cs and the new controls are being added to the form and NOT to the panel itself.
this is weird and iv checked various properties but cannot immediately see the reason for this.
i have made MANY forms before and this is the 1st time this is happening.
one the note of controls, is there a way to change the default value of the labels "AutoSize" property from TRUE to FALSE; i'm using visual studio CE2015
any ideas on what to check? im really stumped by this one.
As mentioned in the comments, you need to check the z-order of your controls.
In the picture below you can see a form I created with two buttons and a panel as you were describing. Neither button is one the panel, however button 3 has a z-order that puts it on top, just as the panel is on top of button 2
If you right click on the controls you want to change the z-order of you see Bring to Front and Send to Back. Choose the appropriate option.

How design left menu panel

in windows wpf i want design a left bar menu like this:
when i click on an item, in the right the window change.
With which control can i design this?
Tab bar control?
Or a left dock panel and insert inside it some button? In this case how can I change the window on the right when click on a button?
If each time you click on a button you want to display a different view, you could define each of your views in a separate control and in your main window within a grid declare each view in a DockPanel.
Then by binding the visibility property of each DockPanel you can create the logic in order to display only what you want on each click.
I suggest using a styled ListBox and binding the Visibility property of your content to it. Even better you can also use a styled Tab control.

Initialization of tabs in tabControl

I'm using tabControl with many tabs(>10), and each tab has UserContol. But tabs Initialize each control at starting my app. It's making my program too slow. I want to run my userControl only when I click on it. How can I do this?
You should improve your UserControls that they do not do the performance stuff until they get activated/visible. Give them a method Activate which the tabcontrol calls when the tabs becomes the selected tab.
Alternatively you could not add the UserControls to the TabPage content in the designer. Instead create your UserControl when the tab becomes active. But this will make them insivible in the Designer.
You could either have a marker such as IsLoaded and until a tab is selected, not load the controls. When the tab is then selected, if it hasn't already been loaded, you could load the controls and add them at runtime to the tabs Controls.
Or, you could have the controls added but not do anything with them until the tab is selected, and then each tab will do the calculations or whatever and update the correct controls.
It's all about your design.
Add a handler to your UserControl's Load event. Then kick off slow activity in the handler.

How to load a new layout in C# when a button is pressed?

I want to load a new layout (just like we do in Android programming as layout1.loadLayout()) in C# when a button is pressed?
How can this action take place when a method is called?
If I am not clear in my question, I am looking to load a new set of controls and hiding the current controls temporarily on a window form when a button is clicked (while they should retain their current properties, so that if I go back they should be in the same way where I left them).
How can I jump between different layouts while not completely deleting and creating them again and again?
if this is for a desktop app, look into user controls.
info here
You could create panels to group controls and toggle it's visibility.
Look for panel control in components, then add controls to it, toogle it's visibility.

WPF WrapPanel with tab stop?

I'm interested into make a wrap panel (plenty of other user control) to be a tab stop. The panel is within a scroll viewer, the scroll viewer do have the IsTabStop property, but the scroll viewer doesn't. I want the user to be able to use tab key to navigate each by one of the user controls located within the wrap papel.
Are you locking for the Focuable property?

Categories