本文主要是介绍Delphi之CxGrid使用技巧三,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在编写某个系统时,由于使用了数据集类型无关技术(即数据集可能是ADOQuery,也有可能是TClientDataSet等等)。当需要对数据进行排序和查找时,只好利用cxGrid自身的功能来实现:
function GridSortColumn(View : TcxGridDBTableView; FieldName : String) : Boolean;
var
i : Integer;
begin
{数据排序}
Result := False;
for i := 0 to View.ColumnCount -1 do
begin
if (UpperCase(View.Columns[i].DataBinding.FieldName) = FieldName) then
begin
View.Columns[i].SortIndex := 0;
View.Columns[i].SortOrder := soAscending;
Result := True;
end
else
begin
View.Columns[i].SortIndex := -1;
View.Columns[i].SortOrder := soNone;
end;
end;
end;
function GridLocateRecord(View : TcxGridDBTableView; FieldName, LocateValue : String) : Boolean;
begin
{数据查找}
Result := False;
if (View.GetColumnByFieldName(FieldName) <> nil) then
Result := View.DataController.Search.Lo
这篇关于Delphi之CxGrid使用技巧三的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!