tabcontrol

Winforms TabControl causing spurious Paint events for UserControl

北战南征 提交于 2019-12-10 17:51:30
问题 For our project, we've written a WinForms UserControl for graphing. We're seeing some strange behavior when our control is sited in a TabControl - our control continuously fires Paint events, even when there is absolutely no activity by the user. We only see this in the TabControl. When we site our control in other containers such as Forms or Splitters, Paint is only fired when you'd expect e.g. when the control is first displayed, etc. Can anyone suggest why this might be happening? Here's a

Hiding/blocking tabs using windows forms in c#

此生再无相见时 提交于 2019-12-10 15:24:08
问题 The thing is that i have a 'log in window' and a 'mainwindow' that is called after pressing the log in button or the "VISITANT" button If pressing the log in button, the whole system will come out, and if i press the VISITANT button, one tab should disappear or be blocked or something. private void visitant(object sender, EventArgs e) { mainwindow menu = new mainwindow(); menu.Show(); //mainwindow.tabPage1.Enabled = false; //attempt1 //mainwindow.tabPage1.Visible = false; //attempt1 //System

Customize TabItem DataTemplate

老子叫甜甜 提交于 2019-12-10 15:13:23
问题 How can I make DataTemplate in WPF for TabItems and in each TabItem customize its content? I need this: <TabControl> <TabControl.ContentTemplate> <DataTemplate> <Label Content="Name" Name="label1" /> <TextBox Name="name" /> ... </DataTemplate> </TabControl.ContentTemplate> <TabItem Header="Add" Name="tabItem1"> <Grid Height="213"> <Button Content="Add" Name="button1" /> </Grid> </TabItem> <TabItem Header="Edit" Name="tabItem2"> <Grid> <Button Content="Edit" Name="button2" /> </Grid> </TabItem

WPF usercontrols on separate tabs: why is radiobutton groupname shared between tabs?

☆樱花仙子☆ 提交于 2019-12-10 12:39:24
问题 I am using a WPF tab control to present separate repeated instances of a user control. i.e. Tab1 for Item1 settings, Tab2 for Item2 settings, and so on. It appears that the radio button group names are being shared between tabs. What is going on? Simple example: A window contains tabs. Each tab contains a user control. <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:lib=

WPF: Disable arrow-keys on tabcontrol

丶灬走出姿态 提交于 2019-12-10 11:27:26
问题 I'm using the WPF TabControl in my application in order to switch between different areas/functions of the program. One thing annoys me though. I have hidden the tabs so I can control the selectedtab, instead of the user. The user however, can still switch between tabs using the arrow-keys. I have tried using the KeyboardNavigation-attribute, but I can't get this working. Can this be disabled? 回答1: You can hook on to the TabControl.PreviewKeyDown event for this one. Check to see if it's the

Access controls from a Usercontrol that is programmatically added more than once?

非 Y 不嫁゛ 提交于 2019-12-10 10:39:33
问题 Well I've search a lot, and can't find help anywhere. I have a form with tabs. When I click a button, a new tab is added, and a usercontrol is added to the new tab. I cannot figure out how to access the controls on the second + tabs. I can access the user controls just fine from the first tab.. just not the others. Here is the code I had so far. private void button1_Click(object sender, EventArgs e) { string title = "tabPage " + (tabControl1.TabCount + 1).ToString(); TabPage newPage = new

TabControl.DrawItem not firing on user painted TabControl

时光怂恿深爱的人放手 提交于 2019-12-10 10:28:24
问题 Hey, I've been trying to paint my own TabControl to get rid of the 3D Shadow but I am not having much success. The DrawItem event isn't firing at the moment. Do I have to shoot it myself? How do I do that? Code: namespace NCPad { public partial class NCE_TabControl : TabControl { Rectangle TabBoundary; RectangleF TabTextBoundary; public NCE_TabControl() { InitializeComponent(); this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this

WPF Flexible TabControl Header

久未见 提交于 2019-12-10 10:03:50
问题 I want to have a TabControl with multiple TabItems . These TabItems each have a header text. These texts may vary a lot in length (like 5 chars long and 15 chars long). I want the TabControl to align the headers in one row only. All tab headers should use the same width, and when there is enough space available, i want them the to use all the space available, up to a MaxWidth , that is the same for all items. So if i want to use vMaxWidth` of 100 for 7 items, the tab header should be max 700

WPF - TabControl - Prevent Selection Change

守給你的承諾、 提交于 2019-12-10 09:00:26
问题 It seems that the WPF TabControl doesn't support the ability to cancel a selection change, since there is no SelectionChanging() event, only a SelectionChanged event. Has anyone figured out a way to do this? The only way I have found is to attach to the PreviewMouseLeftButtonDown() event on each TabItem and set e.Handled to true if I don't want that particular page selected. This seems to work but is clunky. 回答1: I found a way do do this using a style for a TabItem and then binding the

WPF Tabcontrol take size of largest tab

痴心易碎 提交于 2019-12-10 04:12:09
问题 I have a TabControl that is bound to a collection of Viewmodels, which get translated into an appropriate to be drawn into the tab: <Window.Resources> <ResourceDictionary> <DataTemplate DataType="{x:Type charting:LineFormatViewModel}"> <charting:LineFormatView /> </DataTemplate> <DataTemplate DataType="{x:Type charting:IndexSettingsViewModel}"> <charting:IndexSettingsView /> </DataTemplate> .... </ResourceDictionary> </Window.Resources> <TabControl ItemSource="Binding ViewModels" /> I've been