type
TMyForm= class(TForm)
sg : TStringGrid;
imgSortIt: TImage;
...
procedure imgSortItClick(Sender: TObject);
private
{ Private declarations }
// sortIt: TFMXObjectSortCompare;
function sortIt(item1, item2: TFmxObject): Integer;
public
{ Public declarations }
end;
var
frm: TMyForm;
implementation
{$R *.fmx}
procedure TMyForm.imgSortItClick(Sender: TObject);
begin
sg.Sort(???);
...
您好,
我知道如何切换行来手动排序网格......
但由于TSTringGrid
有一个程序Sort
,我尝试将它与我自己的比较函数this procedure一起使用...
我应该如何构建类型/功能以使其工作? 实际上,我得到了:
E2009 Incompatible types: 'regular procedure and method pointer'
感谢您的帮助。
答案 0 :(得分:1)
您正在查看XE3 documentation,根据TFmxObjectSortCompare
声明:
reference to function(Right, Left: TFmxObject): Integer;
在XE2中,遗憾的是,TFmxObjectSortCompare
的声明如下:
function(item1, item2: TFmxObject): Integer;
因此,您需要提供常规程序。也就是说,sortIt
不允许成为类的方法,并且必须只是一个普通的旧函数:
function sortIt(item1, item2: TFmxObject): Integer;
begin
Result := ...
end;
我怀疑这是XE2 FMX代码中的设计错误。排序比较功能比reference to
更灵活,这可能就是它被改变的原因。