944,001 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 10176
  • C# RSS
May 24th, 2005
0

C# : Client windows in client windows

Expand Post »
Hi,

I'm working in C# Windows Forms, with an MDI system. My documents contain several different objects. I want those objects to be shown as dragable windows *inside* the document (MDI client) window, and to be part of that window (ie scroll with it, affect the scroll bars, etc). I've tried to add the windows as children of the MDI client window and I get an error. I've also tried a bunch of other things, none of them work.

Is that possible, or do I have to create several controls to fake it?

I'm not married to the MDI, I just used it to get this to work.... SDI would be fine if I could get #(@!$ child windows to work....

Thanks in advance,

Joe
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Joe Diamond is offline Offline
2 posts
since May 2005
Jun 1st, 2005
0

Re: C# : Client windows in client windows

Well, Joe, I'm new to C#, and I think it's kinda troubling that no one's responded yet to your query.
Basically, the process you seem to be describing can be implemented by setting the "IsMdiContainer" property of what will be your parent window to TRUE.
Then, you create your child objects normally, and whatever control (button or menu) you use to open an instance of a child object, it should have code similar to the following:

protected void MDIChildNew_Click(object sender, System.EventArgs e){
Form2 newMDIChild = new Form2();
// Set the Parent Form of the Child window.
newMDIChild.MdiParent = this;
// Display the new form.
newMDIChild.Show();
}

"Form2" is the name of the child object. This should cause the child object to exist within the confines of the parent window. My only problem with this concept is the lack of control (as far as I know) over the position of the child objects; they cascade by default, which I would rather they didn't do.

There might be easier ways, but this process has worked for me. Hope this helps!
Reputation Points: 10
Solved Threads: 2
Posting Whiz in Training
Toulinwoek is offline Offline
274 posts
since Mar 2005
Jun 2nd, 2005
0

Re: C# : Client windows in client windows

Dear Toulinwoek, (I'm curious about this name, by the way)

Thanks for your kind reply to my question; I was beginning to wonder if I had some kind of special invisible posting account!!

That said, my question was quite esoteric, so not totally surprised.

The process you describe sets up client windows inside an MDI app. I agree it has its limitations, one of which is that when you use it, it's difficult to put windows inside the MDI client windows - if you try to create a form there then you get an error saying you can't add a top-level form to a child form, or something like that.

Fortunately, after several days of searching, and a lot of people telling me
it couldn't be done (not to mention some unanswered posts), I just found out how to do it, which I include for others struggling with this problem:

Forms.frmTest oMyForm = new Forms.frmTest();
oMyForm.TopLevel=false;
this.Controls.Add(oMyForm);
oMyForm.Show();

This, then, allows a top-level form (ie a window) to be added to another window without an error. The bold line is the crucial one.

In addition, I found the following :

There is setting in Options that is hiding some properties.

Go to Tools->Options->TextEditor->All Languages and Uncheck the Hide
Advanced Members CheckBox. . .

The latter didn't seem to make a difference for me, but might help someone
else.

Thanks again for your kind help on this one - it's good to know there are people out there who answer questions....

Have a good one.

JamesCC
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Joe Diamond is offline Offline
2 posts
since May 2005
Jun 2nd, 2005
0

Re: C# : Client windows in client windows

Ah, OK. Now I see; I wasn't fully understanding what you were trying to do, so thanks for sharing what you found. I'll add it to my code library right away!
Reputation Points: 10
Solved Threads: 2
Posting Whiz in Training
Toulinwoek is offline Offline
274 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Azman Help
Next Thread in C# Forum Timeline: how to do autocomplete





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC