用起來和TClientDataSet中不多
如果要複製資料到另一個FDMemTable可以用
function TForm1.CopyFD(mt: TFDMemTable): TFDMemTable; begin Result := TFDMemTable.Create(nil); Result.Data := mt.Data; end;相當的簡單
function TForm1.CopyFD(mt: TFDMemTable): TFDMemTable; begin Result := TFDMemTable.Create(nil); Result.Data := mt.Data; end;相當的簡單
constructor TSmfCxGridPopupMenu.Create(AOwner: TComponent);
begin
inherited;
_CreateMenuItem(); //產生menuitem
end;
constructor TSmfCxGridPopupMenu.Create(AOwner: TComponent);
begin
inherited;
// 確定在 Run Time 時才有作用,不然會重覆
if not (csDesigning in ComponentState) then _CreateMenuItem();
end;
scxGridGroupByBoxCaption = '《托曳欄位至此可群組化》';//'Drag a column header here to group by that column';
TTest<T>.ToString; //不能編譯哦!
begin
Result := f.ToString;
end;
看了半天沒有很好的解決方案
唯一的方式只有這樣TToString<T> = reference to function(const AValue: T): string;procedure TForm2.Button1Click(Sender: TObject);
var
gen : TGenContainer<Integer>;
begin
gen := TGenContainer<Integer>.Create(
function(const AValue: Integer): string
begin
Result := IntToStr(AValue);
end);
end;
也就是說必需在傳入一個函式。
這樣有點麻煩就是
本來以為用若名函數可以搞定:
//以下方法不能編譯過
Button1.OnClick := procedure( sender : tobject ) begin
//...code
end;
結果不能通過。
後來找了好久才發現另外一個妙招,Delphi舊版的也可以用
procedure Click(Self : TObject; Sender: TObject);
var lv : TLvItem;
begin
lv := TLvItem(Self);
//.....code..
end;
function _CreateMenuItem(lv : TLvItem):TMenuItem;
var Meth: TMethod;
begin
Meth.Data := lv;
Meth.Code := @Click;
Result.OnClick := TNotifyEvent(Meth);
end;
var
aDic : TDictionary;
aEnum : TDictionary.TPairEnumerator;
begin
aEnum := aDic.GetEnumerator;
while (aEnum.MoveNext) do
begin
Memo1.Items.Add(aEnum.Current.Key + ' : ' + IntToStr(aEnum.Current.Value));
end;
方法二
var kvp : TPait<integer,string>
begin
for kvp in FList do begin
//kvp.....
end;
end;

