I am using a UltraTabbedMdiManager for a C# winform application. Each tab is added one at a time and displays a unique form. The tab panel is nested within its parent form. I am experiencing two issues related to new tab instantiation.
Issue #1: On adding a new tab the entire tab plane shifts down exposing a strip at the top of the parent form (Mdi container), just below its title bar. When clicking on another tab or elsewhere on the parent form, the tab plane reverts to its original position. This strip only appears on creating a new tab and disappears as soon as the focus is lost (by clicking elsewhere). It also occurs only every second tab that is generated which suggests an activation focus issue on new tabs. The problem does not occur when clicking between already generated tabs or when removing tabs.
I have found a work around for this issue: After the creation of the tab and its form, iterate through all the tabs in the mdi manager and disable them. This iteration is then immediately repeated with enabling all the tabs. The new tab is then reactived. These steps force a loss and then regain of focus and then activation of the tab (N.B. without activation the previous tab will be active). The following is a (verbose) piece of my code which does this operation:
var activeTab = MdiTabManager.ActiveTab;
foreach (var tabgroup in MdiTabManager.TabGroups)
{
foreach (var tab in tabgroup.Tabs)
{
tab.Form.Enabled = false;
}
}
foreach (var tabgroup in MdiTabManager.TabGroups)
{
foreach (var tab in tabgroup.Tabs)
{
tab.Form.Enabled = true;
}
}
activeTab.Activate();
Issue #2: On the generation of some new tabs. The form shifts down and the controls at the top of the previous tab are displayed (but are inactive) on the new tab. It is as if they were superimposed onto the new tab. A similar work around like before resolves this issue; I had read this on another infragistics forum post. However this time the tab's form ShowInTaskbar property is set to false and then true (after iterating through all the mdi managers tabs).
However, the workaround(s) have side-effects if relying on the Application.OpenForms collection. Calling ShowInTaskbar will effectively remove the open forms from this collection (a known Windows form bug as described here Application.OpenForms.Count = 0 always). Unfortunately my application relies on this collection. So my workaround is not applicable to my application. Though, it could be useful to other designs not relying on the OpernForms collection.
It is possible that the two issues are related. Perhaps solved in later version of infragistics. Infragistics does suggest upgrading. Before doing this has anyone experience such problems before?
Just for further information about our application. The form, that contains the mdi manager, is launched from our application's main form. This main form also uses a UltraTabbedMdiManager but does have these issues. Therefore are there known problems with having more than one mdi manager in the same project or solution ?
Here are my environment details:
Infragistics v14.1, .Net v4.7, Visual Studio 2017 Enterprise, C# 7.0, WinForms
Related
I am working on C# application where i am using "Telerik" controls to design the form. I have 5 tabs in Ribbon control having around 15 controls in each tab. The main problem arise when i run the code. It takes some time to load all the controls, it shows grey screen until controls loaded completely. The problem is with InitializeComponent() which is taking time. So is there any solution(s) which i can use so that my designer can load fast and i can avoid slow load of designer. I can't upload full code. But i can give some idea how i have designed.
RadRibbonBar myRibbon;//ribbon control
this.myRibbon.CommandTabs.AddRange(new Telerik.WinControls.RadItem[] {
this.rbnTab1,
this.rbnTab2,
this.rbnTab3,
this.rbnTab4,
this.rbnTab5});//add tabs
this.rbnTab1.Items.AddRange(new Telerik.WinControls.RadItem[] {
this.rbngroup1,
this.rbngroup2,
this.rbngroup3,
this.rbngroup4});//add groups in tab
this.rbngroup1.Items.AddRange(new Telerik.WinControls.RadItem[] {
this.rbnBtn1,
this.rbnBtn2,
this.rbnBtn3,
this.rbnBtn4});//add button in each group
myRibbon.ThemeName = "Office2013Light";
Each tab with 5 groups, each group with 4 button
Apart from this 15 buttons in StartMenu, around 10 controls in QuickAccessToolBar
NOTE: I am adding ribbon control in SplitContainer, and when i add ribbon from designer it takes entire screen to load slow whereas if i load ribbon at the end of window_load event than first it shows remaining controls and than its usual time to show ribbon.
I have a very basic out the box mdiparent which has a number of mdichildren and a menu item. Each button on the menu item hides all the forms and then shows the one respective to that button.
When I do it this way:
//dontHide is the Form we want to show.
for(int i = 0; i < this.MdiChildren.Length; i++)
{
if (this.MdiChildren[i] != dontHide)
{
this.MdiChildren[i].Visible = false;
}
}
dontHide.Visible = true;
Switching forms causes the new form opened to be positioned bit lower and to the right of the old form, but clicking the menu item for the currently displayed form does nothing (as expected).
But, when I do this:
//dontHide is the Form we want to show.
for(int i = 0; i < this.MdiChildren.Length; i++)
{
this.MdiChildren[i].Visible = false;
}
dontHide.Visible = true;
Even clicking the menu item for the currently visible form causes it to shift to the lower right, same as opening a new form. Why is that?
Edit:
I've also noticed when centering the form and then displaying it (so you don't risk having someone glimpse it right before it is moved), setting visible to true completely resets any centering I've done.
This is caused by an obscure implementation detail in Winforms. The native MDI support built into Windows does not support hiding child windows. Winforms works around this restriction by destroying the child window when you set its Visible property to false. And re-creating it when you set it back to true.
This can have various side-effects, the state of the native window is lost when this happens of course. Winforms has fairly decent support for restoring the window again from its properties. But one thing it doesn't do is recreating the window in the same location. So you'll see it getting recreated in the location that new MDI child windows get, staggered from the previous window. Whether that was an oversight or intentional isn't that clear to me, 95% odds for the latter.
Otherwise simple to work around, you can assign the Location property yourself to get it back where it was:
var loc = dontHide.Location;
dontHide.Visible = true;
dontHide.Location = loc;
Or just set the MDI child form's StartPosition to Manual.
So here's my Question, I'm new to C#(teaching my self at that) Here's the thing, I'm working on a basic sim game, nothing to complex but I've got the design and basic functions done.
However In order to implement it, I'm currently using multiple Forms(Visual Studio 2013)
I have my "main" form which has the "action" buttons to it
So when i want to go to a user Profile page I have
Btn_profileview Click(object sender, EventArgs e){
Form profile = new Form();
profile.Show();
}
The User would then implement the changes(for instance change name) which is written to a text file, for use in other areas of the program.
However It opens a new windows, I've tried modal and nonmodal windows and while the benefit of Modal so they have to actual close the window solves the issue, i'd rather have it just overwrite the preexisting Form, and then on close go back to the "main" screen without actually using multiple windows.
Now I was told UserControl and/or Panel would solve the issue, but it would cause a complete redesign moving from the multiple forms to the multiple panel screens and figuring out how to get those to work(Visible and Invisible), i'm assuming it wouldn't be extremely difficult something along the lines of Panel"name".show(); and panel"name".close();
But would it be possible to actually add a line of code to the pre-existing code(so as not to cause a complete reesign) or are Panels and UserControl the only real way to implement within 1 continuous windows?
paqogomez is right: There are many ways to do it.
Here is one that combines a lot of the pros:
You create an invisible Tab on your window with as many pages as you need. Place a Panel on each tab and create all your controls on of them. This does not mean that you have to do it all over - you can move and drop the controls you already have without much hassle. Of course you need to turn off docking and maybe anchors, but other than that this is a simple process.
If you have controls on the 2nd form with the same name, these names should be changed to something unique though. I hope all Controls have proper names already, but especially Labels get neglected, at least here.. (With a little luck you can even use cut and paste to get Controls from another form to panel2!)
The big pro of this trick is that you can do all work in the designer of the same form. The Tab control serves only as a container where you keep your panels without adding to the UI and without giving the user control of what is shown.
Next you create one Panel variable in your main form:
Panel currentPanel;
On Load you assign the first 'real' Panel to it like this:
currentPanel = panel1;
this.Controls.Add(currentPanel);
Later, each time you want to switch, you re-assign the panels you need like this:
this.Controls.Remove(currentPanel);
currentPanel = panel2; // or whichever panel you want to show..
this.Controls.Add(currentPanel );
If your real panels are docked to fill the tabpage, as they should, the currentPanel will fill the form. You still have access to each panel and to each control by their names at any time but you see no overhead of tabs and your form never changes, except for the full content.
I have got a requirement to design a windows forms application using Visual Studio 2010.
According to the design I have to develop the application which contains a menu bar. On selecting of the menus from the Menu bar relevant forms should open. Now as per my requirement these menu forms should be displayed in the same parent Windows Form. Means everything should be in the single form Application.Nothing should be out of that.
The problem that I'm facing is that I don't know how to proceed with this. This is the first time I'm working on Windows Form Application leaving Web.
You are looking for developing an MDI application. MSDN article to guide you - http://msdn.microsoft.com/en-us/library/xyhh2e7e(v=vs.100).aspx
You could build a grid area on your form using a combination of split containers (horizontal and vertical).
Then in separate panels design each of your menu forms, with each panel visibility set to false.
When choosing a menu you would need to assign a parent (split container panel) to the menu form and set it to visible.
Step 1
Create a form and give the name it to "mdiMain" and set the property IsMdiContainer to true.
Add a MenuStrip control from the ToolBar and add some menues.
Step 2
Create another form and give the name it to "frmChild"
Step 3
Write some code in menu click event to display frmChild form in MDI Parent.
Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()
Now your application is ready. You can place your code and control in frmChild window form.
As an option in some cases you can use WebBrowser control and manipulate html code inside depending on the menu bar selection.
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser%28v=vs.110%29.aspx
I am creating my first Windows Forms application, to be deployed on Windows Mobile and I am having some trouble designing a Tabbed Interface.
I had assumed that I could Create a TabControl, then Add some TabPages and then drag Controls on to each Tab Page in turn. This does not appear to be possible and most of the information I see on the web seems to suggest that the controls should be added dynamically at run-time.
Am I missing something obvious here or is this indeed correct?
If you do have to add the controls at runtime then how do people generally manage the design process. Do they create a Custom UserControl for each tab and then add that at runtime?
Design environment (C# Visual Studio 2005, .net 2.0)
Runtime environment (Windows Mobile 6.1)
Update 1
The actual steps taken within visual studio were as follows :-
Select New Project -> SmartDevice -> Windows Mobile 6 Professional -> Device Application
Added a TabControl to Form1. This automatically adds tabPage1 and tabPage2
Update 2
The solution to this is embarrassingly noobish. The TabControl puts the tabs at the bottom of the page, the first thing I was doing was resizing the tab control to a single line which was then hiding the TabPage control.
Currently i don't use Windows Mobile, but i think it works quite the same.
After adding a TabControl to your form you should take a look into the properties and search for TabPages. Here you can add and delete new TabPages to your Control and design it as you like in the designer.
To your question about using UserControls on each TabPage i would definitely say Yes. It makes easier to separate between each page and what will happen on each one.
Also at a last step i am going to move the needed code out of the Designer.cs into my own function (e.g. var tabControl = CreateTabControl() where all of my properties are set. Then i put all my UserControls into an
private IEnumerable<Type> GetAllTypes()
{
yield return typeof(MyFirstControl);
yield return typeof(MySecondControl);
}
and make an
private void CreateTabPages(TabControl tabControl, IEnumerable<Type> types)
{
foreach(var type in types)
{
var control = Activator.CreateInstance(type);
var tabPage = new TabPage();
tabPage.Controls.Add(control);
tabControl.TabPages.Add(tabPage);
}
}
this will then be called by
CreateTabPages(tabControl, GetAllTypes());
With this approach i can easily add another Tab Page with a single line of code and design it in its own scope.
I just opened vs2008 and created a tabcontrol, then I added controls inside using drag and drop in the designer and I didn't found any problem.
The way I use to do it is to create a usercontrol for each tab, But I add the usercontrol to the tab in the designer. (note that the usercontrol will not appear in the toolbox until you generate your solution).
I didn't know why your method are not working. Did you stop your application before try to add the controls?
Good Luck.