Set TabPage Header Color

If you want to color the tabs, try the following code: this.tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed; this.tabControl1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.tabControl1_DrawItem); private Dictionary<TabPage, Color> TabColors = new Dictionary<TabPage, Color>(); private void SetTabHeader(TabPage page, Color color) { TabColors[page] = color; tabControl1.Invalidate(); } private void tabControl1_DrawItem(object sender, DrawItemEventArgs e) { //e.DrawBackground(); using (Brush br = new SolidBrush (TabColors[tabControl1.TabPages[e.Index]])) { e.Graphics.FillRectangle(br, … Read more

Close button in tabControl

Without deriving a class, here is a neat snippet: http://www.dotnetthoughts.net/implementing-close-button-in-tab-pages/ Set the DrawMode property of the Tab Control to OwnerDrawFixed. This property decides whether system or developer can paint the captions. Add the code in the DrawItem event of the Tab Control – This event will be invoked for painting each Tab Page. //This code … Read more

WPF: TabControl & DataTemplates

First of all, there are two templates involved here: TabControl.ItemTemplate, used to render the TabItem headers TabControl.ContentTemplate, used to render the TabItem contents If you don’t set these properties explicitly then WPF will attempt to resolve them elsewhere. It will walk up the logical tree looking for a resource telling it how to render your … Read more

WPF TabItem Header Styling

Try this style instead, it modifies the template itself. In there you can change everything you need to transparent: <Style TargetType=”{x:Type TabItem}”> <Setter Property=”Template”> <Setter.Value> <ControlTemplate TargetType=”{x:Type TabItem}”> <Grid> <Border Name=”Border” Margin=”0,0,0,0″ Background=”Transparent” BorderBrush=”Black” BorderThickness=”1,1,1,1″ CornerRadius=”5″> <ContentPresenter x:Name=”ContentSite” VerticalAlignment=”Center” HorizontalAlignment=”Center” ContentSource=”Header” Margin=”12,2,12,2″ RecognizesAccessKey=”True”> <ContentPresenter.LayoutTransform> <RotateTransform Angle=”270″ /> </ContentPresenter.LayoutTransform> </ContentPresenter> </Border> </Grid> <ControlTemplate.Triggers> <Trigger Property=”IsSelected” Value=”True”> … Read more

Hide Tab headers in WPF TabControl

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> <sys:String>mi</sys:String> </x:Array> </Grid.Resources> <TabControl ItemsSource=”{StaticResource tabData}”> <TabControl.ItemContainerStyle> <Style TargetType=”{x:Type TabItem}”> <Style.Triggers> <DataTrigger Binding=”{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabControl}}, Path=Items.Count}” Value=”1″> <Setter Property=”Visibility” … Read more

Hiding and Showing TabPages in tabControl

I think the answer is much easier. To hide the tab you just can use the way you already tried or adressing the TabPage itself. TabControl1.TabPages.Remove(TabPage1) ‘Could be male TabControl1.TabPages.Remove(TabPage2) ‘Could be female a.s.o. Removing the TabPage does not destroy it and the controls on it. To show the corresponding tab again just use the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)