By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,257 Members | 925 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,257 IT Pros & Developers. It's quick & easy.

Windows Form containing a Windows Form

P: n/a
I have a Windows Form I want to add to another form similar to the way you
add an OpenFileDialog to a Windows Form from the Toolbox.

Thx
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
The OpenFileDialog is not a Windows Form, it is a Component that creates and
displays a form when a certain method is called. I suggest you read up on
creating controls and components. Those sections of the documentation should
have information on how to make a component appear in the toolbox.

"Michael C#" <xy*@abcdef.com> wrote in message
news:LS*****************@fe08.lga...
I have a Windows Form I want to add to another form similar to the way you
add an OpenFileDialog to a Windows Form from the Toolbox.

Thx

Nov 16 '05 #2

P: n/a
Yeah, umm, thanx.

Now, back to business. Can anyone out there point me to some code samples
of how to create a component that creates a form? The tests I ran last
night had some issues including one in which the form tried to instantiate
itself during design time. Thank you.

"Sean Hederman" <us***@blogentry.com> wrote in message
news:cu**********@ctb-nnrp2.saix.net...
The OpenFileDialog is not a Windows Form, it is a Component that creates
and displays a form when a certain method is called. I suggest you read up
on creating controls and components. Those sections of the documentation
should have information on how to make a component appear in the toolbox.

"Michael C#" <xy*@abcdef.com> wrote in message
news:LS*****************@fe08.lga...
I have a Windows Form I want to add to another form similar to the way you
add an OpenFileDialog to a Windows Form from the Toolbox.

Thx


Nov 16 '05 #3

P: n/a
I created a simple Control Library, added a component and a form. Added the
following code to the component:
public DialogResult ShowDialog(IWin32Window owner)
{
frmTest test = new frmTest();
return test.ShowDialog(owner);
}

Created an Application project, referenced the component, and added it to
the Application form, added a button, with the following Click Handler:
private void button1_Click(object sender, System.EventArgs e)
{
myComponent1.ShowDialog(this);
}

Works fine for me, and follows the same general pattern of OpenFileDialog.
It sounds to me like you're trying to create the form in the component
constructor. If that's what you really want to do, why don't you test
against Component.DesignMode?

"Michael C#" <xy*@yomomma.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Yeah, umm, thanx.

Now, back to business. Can anyone out there point me to some code samples
of how to create a component that creates a form? The tests I ran last
night had some issues including one in which the form tried to instantiate
itself during design time. Thank you.

"Sean Hederman" <us***@blogentry.com> wrote in message
news:cu**********@ctb-nnrp2.saix.net...
The OpenFileDialog is not a Windows Form, it is a Component that creates
and displays a form when a certain method is called. I suggest you read
up on creating controls and components. Those sections of the
documentation should have information on how to make a component appear
in the toolbox.

"Michael C#" <xy*@abcdef.com> wrote in message
news:LS*****************@fe08.lga...
I have a Windows Form I want to add to another form similar to the way
you add an OpenFileDialog to a Windows Form from the Toolbox.

Thx



Nov 16 '05 #4

P: n/a
Thank you! I think this will solve my problem. I was using an Inherited
form. It looks like I have to 1) declare the "test" Form variable outside
the ShowDialog function since I need the user to be able update the Form's
properties in some fashion and 2) I'm also going to have to declare a whole
new set of properties for the component that basically mirrors the Form's
properties, with some slight modifications (like using the Title property to
replace the Text property). That's actually the part I'm most hesitant
about... I was hoping there was a simpler way - in which I wouldn't have to
recreate all the Form's properties, etc.

Thanks

"Sean Hederman" <us***@blogentry.com> wrote in message
news:cu**********@ctb-nnrp2.saix.net...
I created a simple Control Library, added a component and a form. Added the
following code to the component:
public DialogResult ShowDialog(IWin32Window owner)
{
frmTest test = new frmTest();
return test.ShowDialog(owner);
}

Created an Application project, referenced the component, and added it to
the Application form, added a button, with the following Click Handler:
private void button1_Click(object sender, System.EventArgs e)
{
myComponent1.ShowDialog(this);
}

Works fine for me, and follows the same general pattern of OpenFileDialog.
It sounds to me like you're trying to create the form in the component
constructor. If that's what you really want to do, why don't you test
against Component.DesignMode?

"Michael C#" <xy*@yomomma.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Yeah, umm, thanx.

Now, back to business. Can anyone out there point me to some code
samples of how to create a component that creates a form? The tests I
ran last night had some issues including one in which the form tried to
instantiate itself during design time. Thank you.

"Sean Hederman" <us***@blogentry.com> wrote in message
news:cu**********@ctb-nnrp2.saix.net...
The OpenFileDialog is not a Windows Form, it is a Component that creates
and displays a form when a certain method is called. I suggest you read
up on creating controls and components. Those sections of the
documentation should have information on how to make a component appear
in the toolbox.

"Michael C#" <xy*@abcdef.com> wrote in message
news:LS*****************@fe08.lga...
I have a Windows Form I want to add to another form similar to the way
you add an OpenFileDialog to a Windows Form from the Toolbox.

Thx



Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.