tabcontrol

C# Tab switching in TabControl

有些话、适合烂在心里 提交于 2019-11-28 09:00:13
问题 Iam facing such problem, which I find hard to overcome. In WinForms I got a TabControl with n TabPages. I want to extend the Ctrl+Tab / Ctrl+Shift+Tab switching. so I wrote some code which works fine as long as the focus is on TabControl or on the Form. When application focus is INSIDE of TabPage (for example on a button which is placed inside of TabPage), while pressing Ctrl+Tab, my code is ignored and TabControl skips to TabPage on his own (avoiding my code). Anyone idea ? 回答1: You need to

How can I bind a List collection to TabControl headers in WPF?

时光毁灭记忆、已成空白 提交于 2019-11-28 08:10:24
I can get data into my TabControl but the headers have frames around them and I can't slick from tab to tab. What am I doing wrong with the XAML binding syntax on this TabControl? XAML: <StackPanel> <TabControl x:Name="TheTabControl"> <TabControl.ItemTemplate> <DataTemplate> <TabItem Header="{Binding LastName}"> <StackPanel Margin="10" Orientation="Horizontal"> <TextBlock Text="{Binding FirstName}"/> <TextBlock Text=" "/> <TextBlock Text="{Binding LastName}"/> </StackPanel> </TabItem> </DataTemplate> </TabControl.ItemTemplate> </TabControl> <TabControl> <TabItem Header="Tab1"> <TextBlock Text=

How to bind items of a TabControl to an observable collection in wpf?

左心房为你撑大大i 提交于 2019-11-28 07:18:58
What is the simplest example of binding the items of a TabControl to an ObservableCollection? Each tab's content will have unique data, and indeed this data will have observableCollections of its own bound to the items components. Currently I have a user control, which I would like to set as the content of each tab as soon as it is created. I also need to dynamically set the datacontext of this new user control when the tab is created. So, essentially, I would like the tabcontrol's observablecollection contain modelviews that map to the data in each tab. On top of that, I need to do all this

Activate tabpage of TabControl

痴心易碎 提交于 2019-11-28 07:07:16
I am using TabControl in #.NET application. By default first tab page of TabControl is showing in form loading. I want to activate/show other tab pages in form loading. Programmatically, how can I show other tab page? tabControl1.SelectedTab = MyTab; Ivan You can use the method SelectTab . There are 3 versions: public void SelectTab(int index); public void SelectTab(string tabPageName); public void SelectTab(TabPage tabPage); Gimly There are two properties in a TabControl control that manages which tab page is selected. SelectedIndex which offer the possibility to select it by index (an

Get and Iterate through Controls from a TabItem?

喜你入骨 提交于 2019-11-28 05:38:21
问题 How to get all the Controls/UIElements which are nested in a Tabitem (from a TabControl)? I tried everything but wasn't able to get them. (Set the SelectedTab): private TabItem SelectedTab = null; private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelectedTab = (TabItem)tabControl1.SelectedItem; } Now I need something like this: private StackPanel theStackPanelInWhichLabelsShouldBeLoaded = null; foreach (Control control in tabControl.Children /*doesnt

Hide Tab headers in WPF TabControl

心已入冬 提交于 2019-11-28 04:40:06
What is the best way to hide Tab headers when there is only a single visible Tab? I want to hide TabControl chrome completely, while leaving the content of the Tab visible. You can use a Style applied to TabItem with a DataTrigger that will collapse it if the parent TabControl has only one item: <Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid.Resources> <x:Array x:Key="tabData" Type="{x:Type sys:String}"> <sys:String>do</sys:String> <sys:String>re</sys:String

Why TabControl.SelectedContent != (TabControl.SelectedItem as TabItem).Content?

限于喜欢 提交于 2019-11-28 01:58:45
问题 The following sample shouldn't beep (in my opinion) but it does. Why? Does that mean the SelectedContent property is useless? Is it a bug in WPF? <TabControl SelectionChanged="TabControl_SelectionChanged"> <TabItem Header="Tab 1"> <Grid/> </TabItem> <TabItem Header="Tab 2"> <Grid/> </TabItem> </TabControl> void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { var t = sender as TabControl; if (t.SelectedContent != (t.SelectedItem as TabItem).Content) Console.Beep(); }

Customizing a TabControl for the Closing of Individual Tabs

限于喜欢 提交于 2019-11-28 00:42:11
My scenario is the following: I am working on a winforms application in C# that has a button inside the main page of a tabcontrol that will generate another tabpage each time that it is clicked. Each new tabpage will contain a layout defined by a user control. My Questions are: How can I allow the user to then close one of the tabs that were created dynamically at runtime? How might I go about modifying the tabcontrol itself so that it has a small 'X' in each tab that the user may click on in order to close that particular tab? (Like Firefox has) How can I expose the SelectedIndex property of

WinForms Hiding TabControl Headers

独自空忆成欢 提交于 2019-11-27 23:40:00
I need some way to hide the headers of a TabControl (I'll be switching the selected tab programatically). How can I do this? Put the tabcontrol in a panel and fixate it so it hides the headers. Easiest is to do it in the code behind (or create a custom control that does this): Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim bordersize As Integer = 3 'could'nt find this on the control. Dim ControlSize As New Size(437, 303) ' the size you want for the tabcontrol Dim ControlLocation As New Point(10, 10) 'location Dim p As New Panel p.Size =

WinForms TabControl - Add New Tab Button (+)

℡╲_俬逩灬. 提交于 2019-11-27 23:13:03
How can I add a + button to the TabControl in a Windows Forms Application. Here is an answer for WPF . But I want it in WinForms application? I would add a new TabPage, then set the header to "+", set it's name to newTabPage and add an event for the TabControl's SelectedIndexChanged. Then you just check if tabcontrol.SelectedTab == newTabPage and if that is the case you can create a new TabPage, insert it into tabControl and set it as the SelectedTab like: tabControl.TabPages.Insert(tabControl.TabPages.Count - 1, createdTabPage); tabControl.SelectedTab = createdTabPage; Reza Aghaei You can add