我有一个 CloseableTabControl 和 CloseableTabItems 我试图动态添加:
public class CloseableTabControl : TabControl
{
protected override DependencyObject GetContainerForItemOverride()
{
return new CloseableTabItem();
}
}
public class CloseableTabItem : TabItem
{
public static readonly RoutedEvent CloseTabEvent =
EventManager.RegisterRoutedEvent("CloseTab", RoutingStrategy.Bubble,
typeof(RoutedEventHandler), typeof(CloseableTabItem));
public event RoutedEventHandler CloseTab
{
add { AddHandler(CloseTabEvent, value); }
remove { RemoveHandler(CloseTabEvent, value); }
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var closeButton = Template.FindName("closeButton", this) as Button;
if (closeButton != null)
closeButton.Click += CloseButtonClick;
}
void CloseButtonClick(object sender, RoutedEventArgs e)
{ …Run Code Online (Sandbox Code Playgroud) 当我单击一个选项卡时,它会显示该选项卡页面的内容,但我想在选择该选项卡时执行一个操作,例如,当我单击“财务选项卡”时,“财务”选项卡中会有一个组合框,组合框应该填充来自sql server的数据,这可能吗?
我有一个带有三个 TabPage 的 TabControl。应用程序的初始启动始终打开左侧的第一个 TabPage。对我来说,有必要设置起始 TabPage(例如第二个)。
\n\n当然,我知道可以像这样更改开始选项卡:
\n\ntabControl.SelectedTab = tabPage;\ntabControl.SelectTab(tabPage);\n...\nRun Code Online (Sandbox Code Playgroud)\n\n但此代码还会激活其他事件来触发,例如 TabControl.Selecting、TabControl.Deselecting、TabControl.SelectedIndexChanged 等。 \xe2\x80\x94 我真的很想提前阻止这种情况。
\n\n我正在寻找的是 TabControl 中的某种属性,例如“StartingTabPageIndex” - 将其设置为 1 将在启动时打开第二个 TabPage,而不会调用任何不必要的事件。
\n我的表单上有tabcontrol组件.我把XPManifest,它的颜色变成白色,我想改变它,但找不到颜色属性.而且我也不想删除XPManifest.有什么方法可以解决这个问题吗?
是否有可用于Delphi的选项卡控件,可以单击选项卡并拖动它们以重新排序它们,就像在Web浏览器中一样?
在我之前的问题中,我可以在运行时向标签页添加一个设计时面板,我的代码看起来像这样,它可以正常工作.
tabControl1.SuspendLayout();
tabControl1.TabPages[0].Controls.Add(panel1);
tabControl1.ResumeLayout();
Run Code Online (Sandbox Code Playgroud)
但现在我需要做这样的事情:
tabControl1.SuspendLayout();
tabControl1.TabPages[0].Controls.Add(panel1);
tabControl1.TabPages[1].Controls.Add(panel1);
tabControl1.TabPages[2].Controls.Add(panel1);
tabControl1.ResumeLayout();
Run Code Online (Sandbox Code Playgroud)
在运行时,我可以知道我需要多少个这样的页面.但现在进行测试我假设我将有三个tabPages
问题是面板只被添加到Last tabPage,我该如何解决这个问题?我希望它被添加到所有标签页谢谢.
在Win7主题中它运行良好,但在赢得经典主题它看起来很奇怪.
在Win 7主题中:

在Win Classic主题中:

有没有机会解决这个问题?
我想在我的winform上以编程方式调整大小选项卡Control.
tabCtrl.Size.Width = Convert.ToInt32(numericUpDown1.Value);
tabCtrl.Size.Height= Convert.ToInt32(numericUpDown2.Value);
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
无法修改'System.Windows.Forms.Control.Size'的返回值,因为它不是变量
知道如何以编程方式调整Tab控件的大小?
如何通过单击"下一步"按钮来制作类似于安装程序的内容,它会在新的上显示您TextBox而不是ComboBox喜欢Panel?
有点像更改标签TabControl但没有显示标签.
我正在制作一个皮肤很厚的应用程序.我试图在WPF中实现一个选项卡控件.我已经开始研究这些tabitems及其各自的背景.但是,我注意到选项卡控件上只有两个tabitems,只用白色填充剩余空间.我有什么属性来改变这个空白区?任何帮助表示赞赏,下面是参考图片以及我的xaml.
图片:

XAML:
<TabControl Margin="0,35,0,0" Background="#1F1F1F">
<TabControl.Resources>
<Style TargetType="TabItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Grid Name="Panel">
<Border Name="Border" BorderThickness="1,1,1,0" BorderBrush="Gainsboro" CornerRadius="4,4,0,0" Margin="2,0">
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="10,2"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Panel" Property="Background" Value="LightGray" />
<Setter TargetName="Panel" Property="TextBlock.Foreground" Value="Black"></Setter>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Panel" Property="Background" Value="#4d4d4d" />
<Setter TargetName="Panel" Property="TextBlock.Foreground" Value="White"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.Resources>
<TabItem Header="Settings">
</TabItem>
<TabItem Header="Results">
</TabItem>
</TabControl>
Run Code Online (Sandbox Code Playgroud) tabcontrol ×10
c# ×6
winforms ×6
.net ×2
delphi ×2
wpf ×2
colors ×1
components ×1
panel ×1
properties ×1
tabpage ×1
vb.net ×1
wizard ×1
wpf-controls ×1
xaml ×1