Are Inherited Forms And/Or Inherited Controls possible in Managed C++
The question is actually pretty self explanatory but I will further clarify it. I am building a simple application to show a load [file] for 5 different types of [files]. So all these 5 forms will have similar GUI elements such as a listbox and a load button with a small textbox/label to show the summary of the [file]'s information.
My desired effect is something like visual studio's C# template for Inherited User controls or Inherited forms. I already heavily googled the concept to look for a C++ visual studio template to the trick but I couldn't find it.
The word [file] is in brac开发者_JS百科kets because open file dialogue will not the trick as this list of files to select form comes form an SQL server.
Thanks a lot!
To further explain my desire:
Class A : public System::Windows::Forms::Form
{
//normal windows forms generated code here and your stuff
}
Class B : public A
{
//You cannot edit this content with designer as designer denies you that chance
}
So I wonder If I can use the designer to edit this class too. I tought if I can make designer not read the class declaration instead see something like this
#if designer
Class B : public System::Windows::Forms::Form
#else
Class B : public A
#endif
{
}
I am looking for something to do this where I can both use the designer on the Inherited form and the Base form. Is it even possible.
Yes, no problem. C++/CLI supports inheritance just as well as any other managed language. What is missing is the point-and-click IDE support, you'll have to type. Add the base form to your project, change the derived Form declaration. For example:
#pragma once
#include "BaseForm.h"
...
public ref class Form1 : public BaseForm // <== NOTE: new base class
{
// etc...
}
It seems it is not possible to use designer on inherited form and controls. Designer for C++/CLI does not support/work on Inherited forms and controls. Could not find the templates for such process too. I will be marking the previos answer as it also correct way to this and answers the big part of my question. Alas there will be no designer support for these forms.
精彩评论