Adding existing "designable" items to an project doesn't work completly

Adding existing forms or components with additional *.Designer.pas files doesn’t work completly.

The files are copied and added to the project, but you have to manually edit the *.elements file if you want to invoke a designer.

This:

<Compile Include="Form2.pas" />
<Compile Include="Form2.Designer.pas" />

must be changed to this:

<Compile Include="Form2.pas">
  <SubType>Form</SubType>
  <DesignableClassName>WindowsApplication1.Form2</DesignableClassName>
</Compile>
<Compile Include="Form2.Designer.pas">
  <SubType>Form</SubType>
  <DesignableClassName>WindowsApplication1.Form2</DesignableClassName>
</Compile>

Applies to SubType “Component” as well.

You don’t need the DesignableClassName, actually, anymore, actually; the compiler now infers that itself (and it’s only needed for the .resx, anyways). you do need DependentUpon on the resx though, for the resource to get the right name.

Can you elaborate on what doesn’t “work completely” without these tags, though?

Sorry - the description could have been “a little” more precise…

1.) I’m not able to invoke the designer - right clicking the imported.pas →

image

Opening the file and invoking the designer via Shift+F7 doesn’t work either.

Snippet from the .elements-file after adding the existing item

<Compile Include="MainXXX.Designer.pas" />
<Compile Include="MainXXX.pas" />
<EmbeddedResource Include="MainXXX.resx">
  <DependentUpon>MainXXX.pas</DependentUpon>
</EmbeddedResource>

If i add the SubType-Tag manually, i am able to invoke the designer after reloading the project.

<Compile Include="MainXXX.pas">
  <SubType>Form</SubType>
</Compile>

2.) Appearence in the project-tree. (Cosmetic issue, after reloading the project the next time, the appearance is as expected.)

image

@viktoriad is this expected, that VS needs these tags to let the designer work?

If so, whats there expectation as to how those would get added “automatically” when adding the files to a project?

Thanks, logged as bugs://85704

bugs://85704 got closed with status fixed.