views:

90

answers:

2

Hello everyone

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 brackets 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.

A: 

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...
}
Hans Passant
Thakns for the answer. Will it be possible to use the designer tool in visual studio on the Inherited Form or control?
Ali Akdurak
It's been 4 hours, I reckon you already figured out that the answer is Yes.
Hans Passant
well it is obviously yes but you cannot use the designer when you inherit from your own ref class even tough it inherits from System::Windows::Forms::Form to better explain the problem I will ad some example code to the question
Ali Akdurak
The designer requires the form to be the first class in the .h file. Use #include.
Hans Passant
A: 

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.

Ali Akdurak