📄 uframgrid.~pas
字号:
SetLength(baBingDing,iColCount);
SetLength(caControlX,iColCount);
for I:=0 to iColCount -1 do begin
baBingDing[I]:=False;
caControlX[I]:=nil;
end;
for I:=0 to High(iaColNo) do begin
II:=iaColNo[I];
if II > FxGrid.Cols-1 then begin
DlgWarningA('Call PBingDingCtrl() Error II > FxGrid.Cols-1');
Exit;
end;
{*****考虑******PBingDingCtrlB()******************************}
if caControl[I] <> nil then begin
baBingDing[II]:=True;
caControlX[II]:=caControl[I];
end;
end;
MySetGridEditCol(baBingDing,caControlX,Self.GridControl);
SetLength(baBingDing,0);
SetLength(caControlX,0);
end;
{**************************参数少一个的函数 等效***PBingDingCtrlA()************
* 必须与表格的列数量等*******************************
******************************************************************************}
procedure TFramGrid.PBingDingCtrlB(caControl: array of TWincontrol);
var
iaTemp:array of Integer;
caTemp:array of TWincontrol;
I,K:Integer;
begin
if FxGrid.Cols-1 <> High(caControl) then begin
DlgWarningA('PBingDingCtrlB=');
Exit;
end;
K:=0;
for I:=0 to FxGrid.Cols-1 do begin
if caControl[I] = nil then K:=K+1;
end;
SetLength(iaTemp,FxGrid.Cols-K);
SetLength(caTemp,FxGrid.Cols-K);
K:=0;
for I:=0 to High(caControl) do begin
if caControl[I] <> nil then begin
iaTemp[K]:=I;
caTemp[K]:=caControl[I];
K:=K+1;
end;
end;
PBingDingCtrlA(iaTemp,caTemp);
end;
{oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
* 标题的填充 充分实现 Fram的最简化
* 取代 函数 MyFillGridCaptionB
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo}
procedure TFramGrid.PFillCaption(saBiaoTi: array of String);
var
K,I:Integer;
begin
PInitFramGrid();{***********简化的关键****************}
MyFillGridCaptionB(saBiaoTi,Self.FxGrid);
I:=Length(saBiaoTi);
SetLength(saFramCaption,I);
for K:=0 to I-1 do begin
saFramCaption[K]:=saBiaoTi[K];
end;
SetLength(iaMaxLength,FxGrid.cols);
end;
{ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
* 读配置 文件 存配置文件
* True Readn False Save
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo}
procedure TFramGrid.PConfigIO(bRead: Boolean);
begin
if bRead then ReadINIGrid(FxGrid);
if not bRead then SaveINIGrid(FxGrid);
end;
{ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
* 设置字端对应的列 用于填充 表格 和 限制编辑筐的长度问题
* 为了简化 一般每一列都对应有字段 如果没有 L_Empty 代替
* L_Empty 代替 ........... L_FieldID 序号
* 参考 FillMsFlexGrid
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo}
procedure TFramGrid.PSetFieldForCol(saFields: array of String);
var
I:Integer;
begin
SetLength(saFramFields,FxGrid.Cols);
if Length(saFields) <> FxGrid.Cols then begin
DlgWarningA('Error=PSetFieldForCol= Length(saFields) <> FxGrid.Cols');
Exit;
end;
{ooo初始化 每列的长度********}
for I:=0 to FxGrid.Cols -1 do saFramFields[I]:=Trim(saFields[I]);
end;
{ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
0 填充表格 代替了原来的函数 FillMsFlexGrid
*ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
0 要实现 的功能 记录 数据的类型
0 数据的长度 200304011 fulin
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
o L_Empty 代替 ........... L_FieldID 序号
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo}
procedure TFramGrid.PFillfxGrid(DBQry:TDataSet);
var
K,I:Integer;
FdTp:TFieldType;
Str:String;
begin
{**检查不保存的列**保存起来 以被其他函数调用 FGetFramGridInSertSQL************}
K:=0;
for I:=0 to High(saFramFields) do begin
if saFramFields[I] = 'L_Empty' then K:=K+1;
if saFramFields[I] = 'L_FieldID' then K:=K+1;
end;
I:=Length(saFramFields)-K;
SetLength(iaSaveCol,I);SetLength(saSaveFd,I);
SetLength(iaNotStrCol,I);
K:=0;
{************************记录 数据的类型****************************}
//if not DBQry.Active then DBQry.Open;
for I:=0 to High(saFramFields) do begin
if (saFramFields[I]<> 'L_Empty') and (saFramFields[I] <> 'L_FieldID') then begin
saSaveFd[K]:=saFramFields[I];
iaSaveCol[K]:=I;
iaNotStrCol[K]:=-2;//默认就不是数字列
Str:=saFramFields[I];
if DBQry.FindField(Str) = nil then begin ShowMessage('DBQry.FindField(Str) = nil='+Str);Exit;end;
FdTp:=DBQry.FindField(Str).DataType;
{***字端类型验证 数据库中 应该只有 数字 字符 blob 三种字端 没有时间子段**}
if (FdTp = ftInteger) or (FdTp = ftWord) or (FdTp = ftSmallint)
or (FdTp = ftFloat) or (FdTp = ftCurrency) or (FdTp = ftFloat) then
iaNotStrCol[K]:=I
else iaMaxLength[I]:=DBQry.FindField(Str).DataSize-1;
{^^^^****是字符 就记录最大长度******}
K:=K+1;
end;
end;
{*******************记录 数据的长度*******DataSize-1***********}
FillMsFlexGrid(saFramFields,fxGrid,DBQry);
end;
procedure TFramGrid.N1Click(Sender: TObject);
begin
FZGridSetA(Self.FxGrid,[0]);
end;
procedure TFramGrid.N2Click(Sender: TObject);
begin
FZGrdiSetName(FxGrid,saFramCaption);
end;
procedure TFramGrid.N3Click(Sender: TObject);
begin
FZGrdiSetName(FxGrid,saFramCaption);
end;
{ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
* 如果字段全部保存 可以用 这个函数
* 如果字段部分保存 还是用
* GetGridInsertSQL 。。GetGridDelSQL
* L_Empty 代替 ........... L_FieldID 序号
* 如果要用到顺序好 比如单据 类 就不用这个函数
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
o FCreateInSertManySQLHN()
* 我曾想过通过 数据表 来验证数据 这样可能很慢
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo}
function TFramGrid.FGetFramGridInSertSQL(sTableName:String): String;
begin
Result:='';
Result:=GetGridInsertSQL(saSaveFd,iaSaveCol,iaNotStrCol,sTableName,fxGrid);
end;
{oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo}
procedure TFramGrid.EdtFloatAKeyPress(Sender: TObject; var Key: Char);
begin
Key:=MyEnterNumberA(EdtFloatA,Key,4);
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.EdtFloatBKeyPress(Sender: TObject; var Key: Char);
begin
Key:=MyEnterNumberB(EdtFloatA,Key,4);
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.N4Click(Sender: TObject);
var
clr:Tcolor;
begin
FSetGridAndTreeColor(clr,FxGrid);
end;
{ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
* 把按钮 绑定到文本筐中去
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo}
procedure TFramGrid.PBingDingBtnToEdit;
begin
SBtnEdtA.Width:=23;
SBtnEdtB.Width:=23;
SBtnEdtA.Top:=0;
SBtnEdtB.Top:=0;
SBtnEdtA.Height:=EdtBtnA.Height-4;
SBtnEdtB.Height:=EdtBtnB.Height-4;
SBtnEdtA.Left:=EdtBtnA.Width-SBtnEdtA.Width-3;
SBtnEdtB.Left:=EdtBtnB.Width-SBtnEdtB.Width-3;
end;
procedure TFramGrid.EdtStrAKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.EdtStrBKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.EdtStrCKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.CmbStrAKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.CmbStrBKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.CmbIntKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.DTPAKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.DTPBKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.EdtBtnAKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
procedure TFramGrid.EdtBtnBKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then Key:=#0;//去掉声音
end;
{*******************************************************************************
* 把网格设置为只读 绑定上的控件自然 不再绑定
* 20030516
*******************************************************************************}
procedure TFramGrid.PSetFramGridReadOnly;
begin
MySetGridEditCol([false,false,false,false,false,false,false,false,false,false,
false,false,false,false],
[nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil],
Self.GridControl);
PSetControlInGridVisible(False);
end;
procedure TFramGrid.PSetFxGridAddState(iFocusCol: Integer);
var
Str:String;
I,J:Integer;
begin
Str:='';
for I:=0 to FxGrid.Rows-2 do
for J:=0 to FxGrid.Cols-1 do
Str:=Str+FxGrid.TextMatrix[I,J];
//FxGrid.Col:= iFocusCol;//原来在这儿//20031125
FxGrid.Rows:=FxGrid.Rows+1;
if Trim(Str)= '' then FxGrid.Row:=FxGrid.FixedRows
else FxGrid.Row:=FxGrid.Rows-2;{倒数第二行}
FxGrid.Col:= iFocusCol;//20031125 符林 Edit Moved Here
FxGrid.OnClick(nil);
end;
procedure TFramGrid.N7Click(Sender: TObject);
begin
FxGrid.AddItem('',FxGrid.Row);
end;
{*******************************************************************************
* 电极最后一行时 是否自动增加
*******************************************************************************}
procedure TFramGrid.PSetAPpendRow(bBiaoShi: Boolean);
begin
if bBiaoShi then iClickLastRowAddOneRow:=0;
if not bBiaoShi then iClickLastRowAddOneRow:=888;
end;
procedure TFramGrid.CmbIntContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
begin
Handled:=True;
end;
procedure TFramGrid.AppEvtMessage(var Msg: tagMSG; var Handled: Boolean);
begin
if Msg.message = WM_PAINT then
if MSg.hwnd = EdtBtnA.Handle then begin
PBingDingBtnToEdit();
end;
end;
function TFramGrid.FControlISNil: Boolean;
var
I:Integer;
begin
Result:=True;
for I:=0 to High(GridControl)-1 do begin
if GridControl[I].conName <> nil then begin
Result:=False;
Exit;
end;
end;
end;
procedure TFramGrid.N8Click(Sender: TObject);
begin
//
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -