tabcontrol

Close button for TabPages of Right To Left TabControl c#

帅比萌擦擦* 提交于 2019-11-26 22:24:32
问题 I want to add a close button to TabPages of a TabControl . I try this code and it works fine with a Left To Right TabControl: private Point _imageLocation = new Point(13, 5); private Point _imgHitArea = new Point(13, 2); this.tabControl2.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed; tabControl2.DrawItem += TabControl2_DrawItem; private void TabControl2_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { try { Image img = new Bitmap(GestionP.Properties.Resources

TabControl and borders visual glitch

让人想犯罪 __ 提交于 2019-11-26 22:22:52
问题 I have these visual glitches on every tabControls when I am changing its tabPages BackColor and the BackColor of the form, as illustrated on the following images: At the top of the tabPage , there is an interior one-pixel white border. At the left of the tabPage , there is an interior three-pixels white border. At the bottom of the tabPage , there is an interior one-pixel white border and an exterior two-pixels white border. At the right of the tabPage , there is an interior one-pixel white

Disable default shortcuts on a TabControl

a 夏天 提交于 2019-11-26 22:05:56
问题 Ctrl + PageUp / PageDown and Ctrl + Tab are default shortcuts for the TabControl. They help in moving between adjacent tabs. I would like Ctrl + PageX behaviour to work only for the outer tabs (tab1, tab2) and Ctrl + Tab behaviour for the inner tabs (tab3, tab4) when my focus is in the control (textbox here). For this, I need to disable the default behaviour. Is there some way to do this? I looked at ProcessDialogKey and IsInputKey, but they seem to work only with single keydata. Modifiers

Customizing a TabControl for the Closing of Individual Tabs

爱⌒轻易说出口 提交于 2019-11-26 21:48:37
问题 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

WinForms TabControl - Add New Tab Button (+)

让人想犯罪 __ 提交于 2019-11-26 21:24:07
问题 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? 回答1: 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

WPF - TabItem Background color changes when tabitem selected or hover over

…衆ロ難τιáo~ 提交于 2019-11-26 21:14:02
问题 I set the Background color of the tabitem in the xaml to RED, but when i run it and hover over it or select it it changes back the the default greyish looking. It only shows correctly when the other tabitem is selected. How do i keep it RED all the time. Thanks! 回答1: Here is example of TabItem ControlTemplate Copy it to your resources and set wherever you need Red color as Background. SAMPLE <Window x:Class="TestCustomTab.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml

How to programmatically select a TabItem in WPF TabControl

给你一囗甜甜゛ 提交于 2019-11-26 20:32:03
问题 I would like to know how to select a specific TabItem in a WPF TabControl. I tried these bellow but nothing work! MyTabControl.SelectedIndex = x MyTabControl.SelectedItem = MyTabItem MyTabControl.SelectedValue = MyTabItem MyTabItem.IsSelected = True 回答1: As @Chris says, any of the first three things should work and as @Phyxx says, it doesn't always really work. The problem is some subtle thing about the order of property changes. To work around it you need to let the WPF invoke your tab

WPF TabControl Databinding

房东的猫 提交于 2019-11-26 19:43:32
问题 I'm trying to build a WPF user interface containing a TabControl, and a TextBlock. I want to bind these two controls to an underlying collection of instances of the following class: class PageModel { public string Title {get;set;} public string TabCaption {get;set;} public FrameworkElement TabContent {get;set} } The tab control should display a tab for each PageModel. Each tab's header should display the TabCaption property Each tab's content should be the TabContent property. The TextBlock

What is the proper way to handle multiple datagrids in a tab control so that cells leave edit mode when the tabs are changed?

两盒软妹~` 提交于 2019-11-26 16:33:46
问题 In wpf I setup a tab control that binds to a collection of objects each object has a data template with a data grid presenting the data. If I select a particular cell and put it into edit mode, leaving the grid by going to another tab this will cause the exception below to be thrown on returning the datagrid: 'DeferRefresh' is not allowed during an AddNew or EditItem transaction. It appears that the cell never left edit mode. Is there an easy way to take the cell out of edit mode, or is

How do I disable visual styles for just one control, and not its children?

蹲街弑〆低调 提交于 2019-11-26 16:29:30
问题 I have a TabControl within a TabControl. I want the outer TabControl to show its tabs on the left. However, with Visual Styles enabled, left-aligned TabControls don't display properly. Can I disable Visual Styles for just the outer TabControl? I'm aware of the third-party TabControl replacements - that's not what I'm after. 回答1: Add a new class to your project and paste the code shown below. Build. Drop the new control from the top of the toolbox onto your form. Visual styles of the child