?? unitrecords.~pas
字號:
unit UnitRecords;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, yhbGrid, ExtCtrls, MapXLib_TLB, UnitAppTypes;
type
TFrame_Records = class(TFrame)
Panel1: TPanel;
Grid_Data: TYHBStringGrid;
Label1: TLabel;
LayerNameEdit: TEdit;
Label2: TLabel;
Label3: TLabel;
RecordCountEdit: TEdit;
ColumnCountEdit: TEdit;
procedure Grid_DataDblClick(Sender: TObject);
private
FLayer: CMapXLayer;
FDataSet: CMapXDataSet;
FSplitter: TSplitter;
FMapX: TMapXObject;
FLayerData: TLayerTreeNodeRecord;
{ Private declarations }
public
{ Public declarations }
procedure InitGrid;
procedure InitGridTitle;
procedure DefWriteGridData;
property MapX:TMapXObject read FMapX write FMapX;
property Layer:CMapXLayer read FLayer write FLayer;
property LayerData:TLayerTreeNodeRecord read FLayerData write FLayerData;
property DataSet:CMapXDataSet read FDataSet write FDataSet;
property Splitter:TSplitter read FSplitter write FSplitter;
end;
implementation
uses
Math, MapXAPIs, MapXBase;
{$R *.dfm}
{ TFrame_Records }
procedure TFrame_Records.InitGridTitle;
procedure InitColumn(ACol:TPropertyColumnItem; fIndex:Integer);
var
AFieldInfo:TMapField;
begin
AFieldInfo:=FLayerData.Fields.FindItem(DataSet.Fields.Item[fIndex].Name);
if AFieldInfo=nil then
ACol.Caption:=DataSet.Fields.Item[fIndex].Name
else
ACol.Caption:=AFieldInfo.DisplayLabel;
end;
var
i:Integer;
ACol:TPropertyColumnItem;
begin
if FLayer=nil then Exit;
ACol:=Grid_Data.Columns.Items[1];
Layer.BeginAccess(miAccessRead);
try
InitColumn(ACol, 1);
for i:=2 to DataSet.Fields.Count do
begin
ACol:=Grid_Data.Columns.Add;
InitColumn(ACol, i);
end;
finally
Layer.EndAccess(miAccessEnd);
end;
end;
procedure TFrame_Records.DefWriteGridData;
var
i, j:Integer;
AValue:OleVariant;
begin
if FLayer=nil then Exit;
Layer.BeginAccess(miAccessRead);
try
for i:=1 to Layer.Selection.Count do
for j:=1 to DataSet.Fields.Count do
begin
AValue:=DataSet.Value[Layer.Selection.Item[i], j];
if VarIsEmpty(AValue) or VarIsNull(AValue) then
Grid_Data.Cells[j, i]:=''
else
Grid_Data.Cells[j, i]:=VarToStr(AValue);
end;
finally
Layer.EndAccess(miAccessEnd);
end;
end;
procedure TFrame_Records.Grid_DataDblClick(Sender: TObject);
var
ARow:Integer;
Ft:Feature;
Seed:Double;
begin
if FLayer=nil then Exit;
ARow:=Grid_Data.Row;
if (ARow>0)and(ARow<Grid_Data.RowCount) then
begin
Seed:=MapX.Bounds.Width/8;
Ft:=FLayer.Selection.Item[ARow];
GoToFeature(MapX, Ft, True, Seed);
end;
end;
procedure TFrame_Records.InitGrid;
begin
if FLayer=nil then Exit;
LayerNameEdit.Text:=FLayer.Name;
RecordCountEdit.Text:=IntToStr(FLayer.Selection.Count);
ColumnCountEdit.Text:=IntToStr(FDataSet.Fields.Count);
while Grid_Data.ColumnCount>2 do
Grid_Data.Columns.Delete(Grid_Data.ColumnCount-1);
Grid_Data.RowCount:=Max(2, Layer.Selection.Count+1);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -