tabcontrol

adding a control to tabs generated dynamically in tabcontrol in C# .net

家住魔仙堡 提交于 2019-12-07 15:36:18
问题 I am new to C# .NET. Can some one help me out with the below problem: I have a TabControl in my WindowsForm application, where the tab pages are generated dynamically. The content to be displayed on each tab would be fetched from my database. I need some kind of control (which can display the fetched data) that I can add on each tab page (which would be same for all tabs) such that I can associate some kind of event, say click, on that added control. Can anyone tell me how to do this

How to prevent delay loading of a UserControl in a TabControl?

Deadly 提交于 2019-12-07 13:51:18
问题 I have just discovered that UserControls in a TabControl will not load until the parent TabPage is selected. Is there a way to prevent this delay loading? I need to initialize the UserControls when the main form loads. 回答1: The TabControl does not treat its controls specially, in fact it is normal under all circumstances for the Load event on a UserControl to occur immediately before the control is displayed for the first time. The TabPage is responsible for showing the control, therefore it

How to change the order of the TabItem in the wpf TabControl

泄露秘密 提交于 2019-12-07 08:57:02
问题 I need to change the order of the TabItem. I've tried with Remove / Insert and it doesn't works. void UserControl_Loaded(object sender, RoutedEventArgs e) { if(condition) { TabControl.Items.Remove(TabItem); TabControl.Items.Insert(0, TabItem); } } InvalidOperationException: Element already has a logical parent. It must be detached from the old parent before it is attached to a new one. How to solve this? 回答1: Solved using the "for" instead of "foreach". if(condition) { var tabItem = Tab.Items

How to make TabPages draggable?

南楼画角 提交于 2019-12-07 07:10:27
问题 I'd like to enable user to rearrange TabPages order by dragging and dropping. Moreover it'd be cool to enable user to drag TabPages from one TabControl to another. Both the way like in Firefox and Total Commander. How to achieve this? 回答1: reordering TabPages with drag and drop - by Ludwig B. inspired by http://dotnetrix.co.uk/tabcontrol.htm#tip7 private void tc_MouseDown(object sender, MouseEventArgs e) { // store clicked tab TabControl tc = (TabControl)sender; int hover_index = this

How to display the same control on two different tabs?

谁说胖子不能爱 提交于 2019-12-07 02:24:08
问题 I'm using VB.NET I need same control (ListBox) to be displayed on 2 different tabs. Is it mandatory to create 2 different ListBox instances? 回答1: If you don't need design-time support you can simply, at runtime, change the ListBox instance's Parent from one tab to the other (making sure to set the positioning appropriately, of course). Essentially, it's: listBox1.Parent = tabControl1.TabPages[1]; In the end though, you'll probably find it easier to just have two ListBox's with the same data

Xaml TabControl in the top of window

混江龙づ霸主 提交于 2019-12-06 22:35:40
Hi All! I have a trouble with xaml-markup design that is shown on a picture. How to place window buttons in one line with tab item headers TAB1 , TAB2 , TAB3 ? I use custom control for window buttons like: <Border> <StackPanel Orientation="Horizontal"> ... buttons ... </StackPanel> </Border> Does anyone have ideas how I can implement this? You will probably have to remove the window border and draw the buttons yourself. You'll have to handle button clicks yourself (don't forget that maximize is also restore when the window is maximized) and also handle window dragging yourself too! <Window x

wpf custom TabControl

◇◆丶佛笑我妖孽 提交于 2019-12-06 14:28:29
I really just want a TabControl that has custom TabItems that are closable, based on code from here . I thought that this question was the same as mine, but the combination of code & xaml below leaves empty tabs. public class ClosableTabControl : TabControl { protected override DependencyObject GetContainerForItemOverride() { return new ClosableTabItem(); } } <uc:ClosableTabControl x:Name="Items" Grid.Column="1"> <uc:ClosableTabControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding DisplayName}" /> </DataTemplate> </uc:ClosableTabControl.ItemTemplate> <uc:ClosableTabControl

Visual Studio is falling apart on me?

我的未来我决定 提交于 2019-12-06 13:37:25
I have a problem that I hope can be fixed. I have been working on a project in VS 2010 - and it seems things are falling apart faster than I can fix them. I have not changed how I am coding or using the designer from the previous months... Here are some screen shots - perhaps someone can help me figure out what's going on here? I know this is rather vague - but I'm pulling my hair out, and maybe someone else has been in this boat! These are from the TabControl craping out on me, an things are missing off my ToolStrips too! HELP! -- Andrew UPDATE The above issues are fixed, and I was able to

How to disable XP themes in WPF application?

江枫思渺然 提交于 2019-12-06 12:00:30
问题 I have a WPF application (.NET 3.0, VS2008) that displays data in a tab control. Custom colors are required on virtually all controls in this application : basically white foreground and green background. My problem is that when an XP theme (say Luna) is active, it is automatically applied to render controls so that my white text is written on ... a white background. For instance on the active tab item header : I have tried : to remove the embedded manifest file from the generated application

C# Winforms TabControl elements reading as empty until TabPage selected

Deadly 提交于 2019-12-06 11:12:30
I have Winform app I am writing in C#. On my form, I have a TabControl with seven pages, each full of elements (TextBoxes and DropDownLists, primarily). I pull some information in with a DataReader, populate a DataTable, and use the elements' DataBindings.Add method to fill those elements with the current values. The user is able to enter data into these elements, press "Save", and I then set the parameters of an UPDATE query using the elements' Text fields. For instance: updateCommand.Parameters.Add("@CustomerName", SqlDbType.VarChar, 100).Value = CustomerName.Text; The problem I have is that