📄 ufrmfindfxgrid.~pas
字号:
{ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
begin
inherited;
if FrmFindFxGrid = nil then
FrmFindFxGrid:=TFrmFindFxGrid.Create(Self);
FrmFindFxGrid.pFxGrid:=@FM.FxGrid;
FrmFindFxGrid.Show;
end;
*******************************************************************************}
unit uFrmFindFxGrid;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, OleCtrls, MSFlexGridLib_TLB;
type
TGridRowAndCol = Record
iCol : integer;
iRow : Integer;
end;
type
TFrmFindFxGrid = class(TForm)
Label1: TLabel;
EdtFind: TEdit;
btnFind: TButton;
Bevel1: TBevel;
BtnUp: TButton;
BtnDown: TButton;
Lblx: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnFindClick(Sender: TObject);
procedure BtnUpClick(Sender: TObject);
procedure BtnDownClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
iCount,iNo:Integer;
RcdX:array of TGridRowAndCol;
public
pFxGrid:^TMSFlexGrid;//必须用指针 回忆主控的输出特性
Procedure PClearColor();
{ Public declarations }
end;
var
FrmFindFxGrid: TFrmFindFxGrid;
implementation
{$R *.DFM}
procedure TFrmFindFxGrid.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
FrmFindFxGrid:=nil;
end;
{ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
*
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo}
procedure TFrmFindFxGrid.btnFindClick(Sender: TObject);
var
I,J:integer;
Str:String;
begin
PClearColor();
if EdtFind.Text = '' then Exit;
if pFxGrid = nil then Exit;
iCount:=0;
SetLength(RcdX,0);
for I:=0 to pFxGrid^.Cols-1 do begin
for J:=1 to pFxGrid^.Rows-2 do begin
Str:=pFxGrid^.TextMatrix[J,I];
if Pos(EdtFind.Text,Str) >0 then begin//找到
iCount:=iCount+1;
SetLength(RcdX,iCount);
RcdX[iCount-1].iCol:=I;
RcdX[iCount-1].irow:=J;
end;
end;
end;
iNo:=-1;
BtnDownClick(Sender);
end;
procedure TFrmFindFxGrid.BtnUpClick(Sender: TObject);
begin
if iCount = 0 then Exit;
iNo:=iNo-1;
PClearColor();
if iNo <= 0 then iNo:=0;
pFxGrid^.Col:=RcdX[iNo].iCol;
pFxGrid^.row:=RcdX[iNo].iRow;
Lblx.Caption:=' 总共找到 '+Inttostr(iCount)+' 个 当前位置 '
+IntToStr(iNo+1)+' 个';
pFxGrid^.CellBackColor:=clred;
end;
procedure TFrmFindFxGrid.BtnDownClick(Sender: TObject);
begin
if iCount = 0 then Exit;
PClearColor();
iNo:=iNo+1;
if iNo >= iCount-1 then iNo:=iCount-1;
pFxGrid^.Col:=RcdX[iNo].iCol;
pFxGrid^.row:=RcdX[iNo].iRow;
Lblx.Caption:=' 总共找到 '+Inttostr(iCount)+' 个 当前位置 '
+IntToStr(iNo+1)+' 个';
pFxGrid^.CellBackColor:=clred;
end;
procedure TFrmFindFxGrid.FormShow(Sender: TObject);
begin
iCount:=0;
end;
procedure TFrmFindFxGrid.PClearColor;
var
I:Integer;
begin
for I:=0 to iCount-1 do begin
pFxGrid^.Col:=RcdX[I].iCol;
pFxGrid^.row:=RcdX[I].iRow;
pFxGrid^.CellBackColor:=clInfoBk;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -