Devexpress RibbonForm inside SplitPanel - c#

As the title says I have a RibbonForm inside a SplitPanel, the problem here is that while I'm being able to place the form inside the panel, the form controls behave strange, specially the TextEdit control. When you try to place the caret between two characters, you can't, instead the whole text is selected. This is what I have
Form2 frm2 = new Form2();
frm2.TopLevel = false;
frm2.Parent = this;
frm2.FormBorderStyle = FormBorderStyle.Sizable;
frm2.WindowState = FormWindowState.Normal;
splContainer.Panel2.Controls.Add(frm2);
frm2.Show();
frm2.BringToFront();
I've tried using MdiParent but to no avail, the behavior stays the same.
I also read that a possible solution is to use a Dock Panel and a User Control instead of a Ribbon Form, the problem here is that I already have 20+ forms developed and fully working so I was hoping to find another solution.
Thank you.

After an exhaustive search, I've found the solution.
The key was to add a DocumentManager, set the main form as its MdiParent, and select a type of View, the next thing was to add this code:
Form2 frm2 = new Form2();
frm2.MdiParent = this;
frm2.Show();

Related

How to insert form into a panel

I am building a material management program using the MetroFramework.
I trying to insert form into a panel to change form when button is click.
But my program occur Exception it is ArgumentException:
Only top-level controls can have an owner.
I dont understand what the problem is.
I'm sorry I do not have enough English.
if (!MainForm.Instance.MainPanel.Controls.ContainsKey("InnerTest"))
{
//inner Test
InnerTest frm = new InnerTest();
frm.TopLevel = false;
frm.Dock = DockStyle.Fill;
MainForm.Instance.MainPanel.Controls.Add(frm);
frm.Show(); // The part that causes the exception
}
Here is my code.
You need to set the ShadowType to none

Adding a form into TabControlPage in C# Windows Forms Application

I have two forms that I am trying to display on a master form using a tabControl element in C#.
I have had no luck so far. How does one go about it?
In your "Child" form, put all your control in a Panel (let's call it "movingPanel") with its Dock property set to Fill and its Modifiers property set to internal. After creating, the child form in the master form, simply do:
theChildForm.movingPanel.Parent = tabControl1.TabPages["The_tabPage_Name"] ;
If you want to host your form into a tab page I think this part of code helps :
newForm.TopLevel = false;
newForm.ControlBox = false;
newForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
newForm.Dock = DockStyle.Fill;
var newTab = new TabPage()
newTab.Controls.Add(newForm);
this.MainTabControl.TabPages.Add(newTab);
this.MainTabControl.SelectedTab = newTab;
newForm.Show();
I hope this is what you are looking for.

Form closing before new shows

Hello I'm making my first Windows Forms app in C# using Visual Studio and I have a little problem.
While I'm opening a new form and closing the previous one, when I run the app it looks like it's closing the previous form before it opens a new one.
It doesn't look good and I want to avoid it.
UserPanel MDIUserPanel = new UserPanel(Username);
MDIUserPanel.MdiParent = this.MdiParent;
MDIUserPanel.Show();
this.Close();
I don't know what is going wrong. I will be thankful for any help.
Wirth regards,
DarQScreaM
#Edit
This doesn't seem to be the case actually. Propably its that :
I have 3 forms MainForm, Login, LoggedUser.
MainForm is MDI container with FormBorderStyle set on Fixed Single
Login is child of MainForm with FormBorderStyle set on None
LoggedUser is child of MainForm with FormBorderStyle set on None
When application is runned Login form is created in MainForm. MainForm is never closed since its container.
But when i move from Login form to LoggedUser form and vice-versa its created with FormBorderStyle = Fixed Single (normal windows window) and after 0.5~second its changed into None.
Editing it into that didn't really help :
MDIUserPanel.FormBorderStyle = FormBorderStyle.None;
MDIUserPanel.Show();
#Edit2
This change fixed it for me. I don't know why setting it on Form properties didn't work properly. It looked like form was created as FormBorderStyle.FixedSingle and then it was changed into FormBorderStyle.None. If I made this manually in Load it worked but U had to fix the size of my window too. It doesn't seem to be good though. It should work from the beginning since Form properties in Designer are like that from the very beginning.
private void UserPanel_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
this.Size = new Size(649, 357);
}
You can use the form's Shown event to ensure that the new form have been showed before you close the old one.
UserPanel MDIUserPanel = new UserPanel();
MDIUserPanel.Shown += ((s, ee) =>
{
this.Close();
});
MDIUserPanel.Show();
If this form you are trying to close, is the main form that opens when you run your application, then that's the reason. Closing the main form will exit your application. Try instead to just hide this form instead of closing it. And to make sure you can exit your application ('cause you've hidden your main form), just override the closing event of your current form, and put an "Application.Exit()" in it.
Hope this helps you !
First Step:
this.Hide();
Second Step:
MDIUserPanel.Show();

.NET MDI child form suppress/hide caption/icon area

I have a subform (child) that I want to use in a number of parents. I'm not a professional developer (I'm an architect - I know, you can save all the jokes... :) - working solo at present). I've ended up using an MDI form with the subform as a child. I maximize the subform form and most things are fine except that although I've tried to disable all the various widgets (the subform in the designer shows NO caption/icon/button area), I get TWO icons on the left and TWO sets of buttons on the right - of which ONLY the restore button works. Either of the sets of buttons will work the one child form.
Is there any way around this? I want the subform to be "transparent" the the user - they shouldn't be aware there's a subform in use.
I've done a quick search and I'd already suppressed the actual caption as mentioned in another answer - to get the caption bar suppressed in the designer...
Is MDI the right technology, or is there a better way to have the same subform appear in multiple parent forms?
VS2008, C#, Windows 7
TIA,
Paolo
There's a WF bug that will double the glyphs if you create the MDI child form in the parent's constructor. Here's an example:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
this.IsMdiContainer = true;
var child = new Form();
child.MdiParent = this;
child.WindowState = FormWindowState.Maximized;
child.Show();
}
}
Move the child form creation code to the Load event to avoid this.

C# question - make form visible

I made 2 forms in C# visual studio.
How can I make one form invisible and another visible (Have done this in visual basic only before)
I guess Syntax should be similar.
Use the Form.Visible property, or the Form.Show() method.
To hide and show a form, use the Form.Visible property:
Form.Visible = true;
Form.Visible = false;
There's also methods that do the same thing (these are designed to be used with the MethodInvoker delegate):
Form.Show();
Form.Hide();
If I remember correctly, VB.NET will pre-create the forms for you, and you only have to call Show(). In C#, you will have to create all but the MainForm.
// in a buttonClick on Form1
Form2 f2 = new Form2();
f2.Show();
This will create a new instance each time you click the button.
Use the property Visible of the class Form.

Categories

Resources