WPF WrapPanel with tab stop? - c#

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?

Related

Attach button to panel

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.

DataGridView shuffling column widths depending on visibility when control is added

Both the 'Load' button on tabPage2 and the 'Load' Menu Item are running the same code, but as you can see in the demo above when the control is added when tabPage2 is not selected, the column widths shuffle despite it being the exact same code, the exact same control with the exact same content.
I'm not sure how relevant it is to the problem, but the UserControl I am adding looks like this:
Just a tab control with two tabs, a split container on the first tab with a DataGridView in the bottom split panel.
Each 'Load' creates a new tab page, a new user control, adds the user control to the tab page and then adds the tab page to the tab control on tabPage2.
Is there something at play here that I'm not aware of that would make controls render differently depending on their visibility when added?
EDIT: The DataGridView's are using DataGridViewAutoSizeColumnsMode.Fill
It does not have anything to do with the visibility of the tabs when adding the user control. To confirm you can keep the tabPage2 selected and you will see the same behavior as you currently have.
It is the selection and highlights of the tab controls that must be giving that notion. You can try adding around 4 user controls and click between tab2 and tab3 to confirm.

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 Change TabPage Position in C#.NET?

I have six tabs on my Windows application. I need to put tab #6 after tab #2, how can i do it?
I couldn't drag the tab to the location i want! The 5 tabs are full of controls that took long time to name and design. Any idea how to move last tab and place it after 3rd tab?
In order to arrange the tabs in a TabControl, access the property dialog for the TabControl and find the "TabPages" property. Clicking on the little button next to the value field will display a dialog which will allow you to control the properties and position of each tab in the TabControl.
TabPages Property http://img16.imageshack.us/img16/6334/tabeditor.png
Although an answer is there: I thought this picture may speak few more words ;)
Click on Tab Control
Go to Properties Window
Click on Tab Page as highlighted in blue
Voila! The TabPage Collection Editor allows you to perform what you need. It's intuitive.

How do I make a single control appear across many tab control pages?

I have a WPF tabcontrol with 3 tabs. On the top of the first page is a scrollviewer with a couple buttons which make up a menu of common tasks (save, load etc). I would like this scroll viewer to appear at the top of every tab. Is it possible to do this without simply copying and pasting the code to every tab?
You can make a custom control that contains the UI and logic for the buttons, and then include that control on each tab. The best way to do this is to create a subclass of ScrollViewer, and in the XAML define each of the buttons. On each of your tab pages you can create and create an instance of your new subclass.
This will result in a different instance of your class on each page, but the logic for the buttons will only exist in the code once.
You could implement the scroll viewer and buttons outside and on top of the tabcontrol.

Categories