我试图使用自定义类的数组作为我的组件的属性,但问题是值没有保存到组件,这意味着如果我设置值,保存所有内容并再次打开项目,组件的值消失了...我的代码如下所示:
unit Unit1;
interface
uses Windows, ExtCtrls,Classes,Controls;
type
TMyClass=class(TPersistent)
private
FName: string;
FValue: double;
public
property Name: string read FName write FName;
property Value: double read FValue write FValue;
end;
TMyComponent= class(TCustomPanel)
private
FMyArray: array[0..200] of TMyClass;
function GetmyArray(Index: Integer): TMyClass;
procedure SetMyArray(index: Integer; Value: TMyClass);
public
property myArray[index: Integer]: TMyClass read GetMyArray write SetMyArray;
end;
implementation
function TMyComponent.GetmyArray(Index: Integer): TMyClass;
begin
result:= FmyArray[Index];
end;
procedure TMyComponent.SetMyArray(index: Integer; Value: TMyClass);
begin
FMyArray[index].FName:= Value.FName;
FMyArray[index].FValue:= Value.FValue;
end;
end.
Run Code Online (Sandbox Code Playgroud)
我知道只有已发布的属性可以流式传输,但问题是我的属性是一个数组而且无法发布...我的建议是DefineProperties()用来提供自定义流式传输,但我不知道如何用数组做这个.我认为的其他可能性是将TMyClass修改为TMyComponent可以作为它的父类的类,就像它在TChart中完成的那样,你可以为它添加不同类的系列.但我不知道这应该是什么课 …
我在尝试获取查询中的特定值时收到以下消息
"指定的字段可以引用多个表"
很明显,我正在尝试搜索多个表中存在的内容,但是如何做到这一点呢?
现在我有以下代码:
SELECT Table1.CustomerId, Table1.Address,
Table2.CustomerId, Table2.Telephone,
Table3.CustomerId, Table3.Notes
FROM (Table1 INNER JOIN Table2 ON Table1.CustomerId=TAble2.CustomerId)
INNER JOIN Table3 ON Table2.CustomerId=Table3.CustomerId
WHERE CustomerId = 0015
Run Code Online (Sandbox Code Playgroud)
最后一句是问题......任何想法?
我有以下组件,其中包含从自定义类派生的属性:
unit MyComponentTest3;
interface
uses Windows, ExtCtrls,Classes,Controls;
type
TMyClass3 = class
myString: string;
myNumber: double;
end;
TMyComponentTest3 = class(TCustomPanel)
private
FMyProperty: TMyClass3;
procedure SetMyProperty(Value: TMyClass3);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetMyPropertyPublic(AmyString: string; AmyNumber: double);
published
property MyProperty: TMyClass3 read FMyProperty write SetMyProperty;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyComponentTest3]);
end;
{ TMyComponentTest3 }
constructor TMyComponentTest3.Create(AOwner: TComponent);
begin
inherited;
FMyProperty:= TMyClass3.Create;
end;
destructor TMyComponentTest3.Destroy;
begin
FMyProperty.Free;
inherited;
end;
procedure TMyComponentTest3.SetMyProperty(Value: TMyClass3);
begin
with FMyProperty do …Run Code Online (Sandbox Code Playgroud) 我有一个可以在运行时或设计时创建的表单来帮助组件.但是,我需要知道这个表单是在设计还是运行时打开,有人知道怎么做吗?
我在使用双精度变量计算简单算术方程时遇到问题.
我有一个具有属性值的组件具有双精度,我将此属性设置为100.
然后我做一个简单的减法来检查这个值是否真的是100:
var
check: double;
begin
check:= 100 - MyComponent.Value
showmessage(floattostr(check));
end;
Run Code Online (Sandbox Code Playgroud)
问题是我没有得到零,我得到-1.4210854715202E-14,这是一个问题,因为我程序检查这个结果是否正好为零
任何想法如何解决?
我想知道是否可以在运行时知道组件的类别.例如,如果我有一个TLabel,则类别为标准,这意味着组件TLabel位于标准工具选项板中.
我需要检查组件是否是我自己的创作之一,因为我有很多新组件,我不想检查很多ifs条件......
谢谢
我有一个表单,我编写了自己的构造函数:
constructor Create(AOwner: TComponent; AParent: TWinControl; ASender: TMyClass;
ATab: String); reintroduce; overload;
Run Code Online (Sandbox Code Playgroud)
要创建这样的表单,我使用以下内容:
try
MyForm := TMyClassForm.Create(nil, Self.Parent, Self as TMyClass, 'FirstTab');
MyForm.ShowModal;
finally
MyForm.Free;
end;
Run Code Online (Sandbox Code Playgroud)
在其他地方,在开始一个程序之前,我需要检查这个表单是否被打开,所以我检查它的存在:
if (Assigned(MyForm)) and (MyForm.Active) and (MyForm.Showing) then
// Don't do the procedure
else
// Do the procedure
Run Code Online (Sandbox Code Playgroud)
现在,如果我打开表单并关闭它,并且我检查这个条件语句,每次我都变为现实,但表单没有打开而且不再显示,因为我在创建后释放了它.
什么可能是问题的任何想法?
delphi ×6
components ×4
class ×2
forms ×2
categories ×1
constructor ×1
database ×1
design-time ×1
ms-access ×1
mysql ×1
runtime ×1
sql ×1