Convert Form to UserControl

Posted by Joe on Stack Overflow See other posts from Stack Overflow or by Joe
Published on 2010-02-04T00:17:54Z Indexed on 2010/04/09 18:43 UTC
Read the original article Hit count: 339

Filed under:
|
|

I have a 3rd party code library that I'm using; part of this library is a winforms application for editing the configuration files used by this library. I would like to embed their configuration editor app into my application.

I have the source code to their library and the configuration editor is (as far as I can tell) a straight forward Winforms app using standard controls. I'm trying to convert the app's main form into a UserControl so that I can host it inside my application which is WPF (WPF's WindowsFormsHost won't host a Form object, I get an exception).

I changed the form object to inherit from UserControl instead of Form and fixed all the compiler errors (there weren't many, just property initializations that don't exist on UserControls) but what's happening is my newly converted control is just blank.

When I run my test app I don't see any of the controls that make up the original form, just a blank page.

Any ideas? I really don't want to have to re-implement their app from scratch, that would suck.

Edit: I forgot to mention I'm testing this in a WinForms application, not WPF, to just get the control working before trying to use it from WPF.

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms