-1

So I have a delphi combobox that looks like this (Rad Studio 2007 .net)...

TEnumComboBox<T> = class(TComboBox)

the idea is that it can take any enum type and populate itself from there. Struggling to actually get the form that it's used in to compile. I have something in the nfm...

object DataTypeBox: TEnumComboBox<DataType>
...
end

and something in the pas file, in the published bit...

DataTypeBox : TEnumComboBox<DataType>;

I get the following error:

Error: E2217 Published field 'DataTypeBox' not a class or interface type

If I move the declaration of DataTypeBox out of the published bit and into the private bit I get a DCC error code 1.

So, am I wasting my time trying to get a generic control to work in delphi 2007 (Delphi for Microsoft .NET)? Thanks.

J...
  • 30,968
  • 6
  • 66
  • 143
flobadob
  • 2,804
  • 2
  • 22
  • 23
  • 1
    Yes, you are wasting your time. Use a method that doesn't have generics. – David Heffernan May 03 '18 at 13:30
  • This doesn't work in other .NET designers so I expect it won't be possible here. You might try defining a concrete type - `TDataTypeEnumComboBox = TEnumComboBox` and try sticking that in the form file, ie : `object DataTypeBox: TDataTypeEnumComboBox`. – J... May 03 '18 at 15:22
  • 1
    You cannot use Generic types in DFMs, they are simply not supported. Only concrete classes without Generic parameters are supported. – Remy Lebeau May 03 '18 at 20:42

1 Answers1

0

Delphi 2007 did not support generics. They were introduced in Delphi 2009.

Stefan Glienke
  • 20,860
  • 2
  • 48
  • 102
  • 1
    Sorry, we are using Delphi .NET 2007 (whether the .NET makes a difference or not, I don't know). Anyway we are using generics in our pas files all over the place, but we've never tried to use generics in a control type. – flobadob May 03 '18 at 12:26
  • Yes, a quick search reveals that the Delphi .NET 2007 compiler supports generics. – flobadob May 03 '18 at 12:30
  • @flobadob That's information that needs to be included in the question. Please edit it to include those important details. – David Heffernan May 03 '18 at 13:29
  • 1
    The *compiler* may support Generics, but the RTL's *DFM streaming system* does not – Remy Lebeau May 03 '18 at 20:43