![]() |
String als default bei propertys ???
Delphi-Quellcode:
Bei den ersten 2 mekert der Compiler das es Ordinale, Pointer oder SmallSet sein müssen.
property ComPort: String read VComPort write SetComPort default DefaultComPort;
property Parity: String read VParity write SetParity default DefaultParity; property Databits: Integer read VDatabits write SetDatabits default DefaultDatabits; property Stopbits: Integer read VStopbits write SetStopbits default DefaultStopbits; Wie kann ich dann den default bei strings definieren??? Mfg Tobi |
Re: String als default bei propertys ???
strings :
'0' 'x' 'dijfjfsöafjdsklfdskaös' :P |
Re: String als default bei propertys ???
Zitat:
|
Re: String als default bei propertys ???
Zitat:
Tada... Zitat:
Zu Deutsch: Im Konstruktor händisch zuweisen, anders dürfts ned gehn. @Hansa: :thumb: :roll: :wall: greetz Mike |
Re: String als default bei propertys ???
:wiejetzt:
Nommal meine Frage: Wie kann ich einen Default im Stringformat erstellen? Sodass in der Kompo im OI bei Comport standatirisiert Com1 drinsteht. Zitat:
Zitat:
|
Re: String als default bei propertys ???
Ich glaube, du gehst den falschen Weg ;) Wieso willst für diese Eigenschaften denn String-Properties? Sind doch eigentlich Integer. Im OI wird sowieso alles als string dargestellt.
Solltest du aber unbedingt strings haben wollen, musst du die Werte im Konstruktor zuweisen. @Hansa: nimm dir bitte mal fkerber's Avatar zu Herzen. |
Re: String als default bei propertys ???
Für strings gibt es nunmal keine defaults.
|
Re: String als default bei propertys ???
Zitat:
Wie geht das mit dem Constructor??? //EDIT Bei Labels steht ja in der Caption standarisiert auch Label1 drin ;-) |
Re: String als default bei propertys ???
Deine Komponente hat doch bestimmt eine OnCreate-Prozedur, oder?
Und da schreibst du einfach rein:
Delphi-Quellcode:
Eine andere Möglichkeit wäre eine Variable dieses Typs (statt String):
Port:= 'Com1';
Delphi-Quellcode:
type
TPort = (Com1,Com2,Com3); |
Re: String als default bei propertys ???
Delphi-Quellcode:
@CK_CK: OnCreate ist ein Event von TForm und noch paar andren Klassen, wenn ich mich nich irre... Meinst du AfterConstruction?
type
MyComponent = class(TComponent) private fPort: string; public property Port: ... ; constructor Create; override; end; implementation constructor MyComponent.Create; begin inherited Create; fPort := 'com1'; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:22 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz