tabcontrol

Programmatically hide/remove tabpages in VB.NET

旧巷老猫 提交于 2019-12-04 03:47:13
问题 I have 10 tabpages on my form. Based on an input in a textbox, I want to programmatically remove number of tab pages, i.e. if textbox input is 3 then only first 3 tabpages should be visible and tabpages 4 to 10 must be removed or should not be visible. I tried following without any success, For i = 0 To 9 Form1.TabControl1.TabPages.Remove(Form4.TabControl1.TabPages((val(textbox1.text)) + i)) Next (No exceptions or errors are generated for above statements) What is wrong with these statements?

Remove TabPage: Dispose or Clear or both?

╄→гoц情女王★ 提交于 2019-12-04 03:42:27
问题 I am working on a windows form that has a TabControl named tabDocuments. I came across this piece of code that removes all pages from the TabControl. for (int i = tabDocuments.TabPages.Count - 1; i > -1; i--) { tabDocuments.TabPages[i].Dispose(); } tabDocuments.TabPages.Clear(); The person who wrote this code has already left a while ago. I am trying to understand why the code is calling Clear() after disposing each of the tabPages (looks un-necessary to me). Can anyone please explain to me

Cant get a control from a TabControl DataTemplate

雨燕双飞 提交于 2019-12-04 03:35:12
问题 I've been googling this for the last 2 days and cant get anywhere, I just cant do anything to any control in a datatemplate of a tabcontrol. First off, the code: private void Window_Loaded(object sender, RoutedEventArgs e) { tabControl1.ItemsSource = new string[] { "TabA", "TabB", "TabC" }; } private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e) { ContentPresenter cp = tabControl1.Template.FindName("PART_SelectedContentHost", tabControl1) as ContentPresenter;

How to change background color of TabControl.Header

这一生的挚爱 提交于 2019-12-03 22:49:53
I need to change the background color of the TabControl header, but TabControl haven't property for it, how can I do it. Help me please. Here is my code: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="502" Width="628"> <TabControl Background="#123" TabStripPlacement="Left" HorizontalAlignment="Stretch" BorderBrush="#41020202"> <TabControl.BitmapEffect> <DropShadowBitmapEffect Color="Black" Direction="270"/> </TabControl.BitmapEffect> <TabControl

How to set the default style for tabitem in a tabcontrol's style

江枫思渺然 提交于 2019-12-03 17:47:40
问题 I'm creating a specific style for some TabControl in my application. <TabControl Style="{StaticResource MyTabControl}"> </TabControl> I want to also style TabItem in the case of this specific TabControl's Style. For now, I must write : <TabControl Style="{StaticResource MyTabControl}"> <TabItem Style="{StaticResource MyTabItem}" Header="First" /> <TabItem Style="{StaticResource MyTabItem}" Header="Second" /> </TabControl> Instead of having to specify the "MyTabItem" style on each TabItem, is

How to add new user control in TabControl.ContentTemplate?

一笑奈何 提交于 2019-12-03 16:23:53
I am little stuck with adding new instances of a usercontrol in a TabControl.ContentTemplate ? My Xaml is here: <TabControl ItemsSource="{Binding Tables}"> <TabControl.ItemTemplate> <DataTemplate> </DataTemplate> </TabControl.ItemTemplate> <TabControl.ContentTemplate> <DataTemplate DataType="{x:Type uc:mytest1}"> <uc:mytest1> </uc:mytest1> </DataTemplate> </TabControl.ContentTemplate> </TabControl> I am binding TabControl.ItemsSource property to an ObservableCollection and in the content template I am adding a user control, but when this app runs I am getting new items as TabItem s but the

TabControl: all TabItems collapsed, but content of 1st TabItem still visible

余生颓废 提交于 2019-12-03 16:15:50
I've got a rather strange behavior on a TabControl, whose TabItems are all collapsed: The content of the first TabItem is still visible (but the header is not). The TabControl and its TabItems are setup like this: <TabControl> <TabItem Header="Data 1" Visibility="{Binding Path=DataTable1.HasRows, Converter={StaticResource BoolToVisibility}}"> <UI:ShowData DataContext="{Binding Path=DataTable1}"/> </TabItem> <TabItem Header="Data 2" Visibility="{Binding Path=DataTable2.HasRows, Converter={StaticResource BoolToVisibility}}"> <UI:ShowData DataContext="{Binding Path=DataTable2}"/> </TabItem> <

How to change the color of the selected tab in the TabControl?

筅森魡賤 提交于 2019-12-03 13:37:31
I am implementing a TabControl for a dialog box in WPF. The color of the selected tab (mouse-down) is white by default. I want to change the color of that selected tab to the color of hover (when I hover over a tab, the color of the tab changes to an Office-blue-gradient, which is what I want the color of the selected tab to be on mouse-click). How can I do that? This piece of code does not work: <Style x:Key="StyleTabControl" TargetType="{x:Type TabItem}"> <Setter Property="Background" Value="#FFFDFDFD"/> <Style.Triggers> <Trigger Property="IsSelected " Value="True"> <Setter Property=

Can I remove the dotted focus rectangle over tabs on a TabControl?

不羁的心 提交于 2019-12-03 12:41:30
I have a tab control and need to remove the dotted focus rectangle around the selected tab. I have set the TabStop property of the TabControl to false. However if I click on a tab and press the Tab key, the dotted rectangle appears around the tabname. I have tried creating my own TabControl and tried this class MyTabControl : TabControl { public MyTabControl() { TabStop = false; DrawMode = TabDrawMode.OwnerDrawFixed; DrawItem += new DrawItemEventHandler(DoMoreTabControl_DrawItem); Invalidate(); } } However, the dotted rectangle still appears. I also tried overriding the MyTabControl.OnPaint()

WinForms Tab Control question

痞子三分冷 提交于 2019-12-03 08:47:52
I have a form that displays in two modes. Switching modes completely changes the appearance of the form much like you would expect if you were using a tab control and had a different layout of controls on each tab. A tab control would be perfect if I could hide the tab itself. Of course, I could use two panels and pro grammatically show and hide the appropriate panels. I tried this, but my anchoring keeps on getting messed up (I think it is a Visual Studio designer bug.) Ideally, I'd like to use a "wizard" control, which is tab-less, and at designtime, draw the controls for the first page,