作为一个delphi初学者来说,自己得来的经验十分珍贵,今天由于新建了一个windows新账户差点导致原来放在桌面上的代码无法找回,现把它们记录下来,及备后用
- procedure TfrmServerSetup.DBAdvStringGrid1MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- Var
- s:string;
- GrdCrd: TGridCoord;
- begin
- GrdCrd := TDBAdvStringGrid(Sender).MouseCoord(X, Y);
- if Button=mbRight then
- begin
- s:=inputbox('修改列值','输入值','0');
- //这里要设置这些Grid的tag属性,把sender强制转换为TDBAdvStringGrid类型,根据tag判断是哪一个Grid
- case TDBAdvStringGrid(sender).Tag of
- 1: ColumnModify(GrdCrd.X,s,adotable1);
- 2: ColumnModify(GrdCrd.X,s,adotable2);
- 3: ColumnModify(GrdCrd.X,s,adotable3);
- 4: ColumnModify(GrdCrd.X,s,adotable4);
- 5: ColumnModify(GrdCrd.X,s,adotable5);
- 6: ColumnModify(GrdCrd.X,s,adotable6);
- end;
- end;
- end;
- procedure TfrmServerSetup.DataProcess(str:string;adotb:TADOTable);
- var
- i:integer;
- begin
- with adotb do
- while not eof do
- begin
- i:=0;
- while i<=23 do
- begin
- edit;
- adotb.fieldvalues['time'+inttostr(i)]:=str;
- i:=i+1;
- end;
- adotb.Next;
- end;
- end;
- procedure TfrmServerSetup.BitBtn3Click(Sender: TObject);
- Var
- s:string;
- begin
- s:=inputbox('修改全表','输入值','0');
- if pagecontrol1.ActivePage=tabsheet1 then
- begin
- DataProcess(s,adotable1);
- end;
- if pagecontrol1.ActivePage=tabsheet2 then
- begin
- DataProcess(s,adotable2);
- end;
- if pagecontrol1.ActivePage=tabsheet3 then
- begin
- DataProcess(s,adotable3);
- end;
- if pagecontrol1.ActivePage=tabsheet4 then
- begin
- DataProcess(s,adotable4);
- end;
- if pagecontrol1.ActivePage=tabsheet5 then
- begin
- DataProcess(s,adotable5);
- end;
- if pagecontrol1.ActivePage=tabsheet6 then
- begin
- DataProcess(s,adotable6);
- end;
- end;
- //左键双击关闭pagecontrol中的一个分页即一个tabsheet,功能像遨游浏览器一样
- procedure TfrmServerSetup.PageControl1MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- Index: Integer;
- begin
- //左键点击并且双击
- if (Button = mbLeft) and (ssDouble in Shift) then
- begin
- Index := PageControl1.IndexOfTabAt(X, Y);
- if Index >= 0 then
- PageControl1.Pages[Index].Free;
- end;
- end;