procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);begin //首先将窗体的keypreview设为true //禁止按delete 删除键 if Key=46 then begin //ShowMessage(‘ok‘); Key=0; end; //首先将窗体的keypreview设为true //禁止按backspace 返回退格键,这里如果Edit内容为数字则这个方法不好用,有待研究 if key=8 then ...
//fromhttp://kingron.myetang.com/zsfunc12.htm(*//标题:处理数据网格的编辑框说明:示例添加焦点颜色;获取还没有提交到数据集的字段文本设计:Zswang日期:2002-03-31支持:wjhu111@21cn.com//*)///////Begin Sourcefunction GetDBGridEdit(mDBGrid: TDBGrid): TEdit;var I: Integer;begin Result := nil; if not Assigned(mDBGrid) then Exit; if not mDBGrid.EditorMode then begin ...
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls;type TForm1 = class(TForm) DataSource1: TDataSource; ADOTable1: TADOTable; DBGrid1: TDBGrid; Button1: TButton; procedure DBGrid1DblClick(Sender: TObject); private { Private declarations } public { Public declarations } // var ...
在一个Dbgrid中显示多数据库 在数据库编程中,不必要也不可能将应用程序操作的所有数据库字段放入一个数据库文件中。正确的数据库结构应是:将数据库字段放入多个数据库文件,相关的数据库都包含一个唯一的关键字段,在多数据库结构里可以建立联系。 例如:要编制一个人事管理程序,为简化演示程序,只建立两个数据库,每个数据库都只建立两个字段。 个人简介 jianjie.dbf,由人事处维护;工资情况 gongzi.dbf,由财务处...
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DM.FirstListStatus.AsString=‘生产‘ then begin
First_DG.Canvas.Font.Color:=clGreen
end
else begin
First_DG.Canvas.Font.Color:=clRed;
end;
if DataCol = 4 then
First_DG.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
2、多种改变方式
[delphi] view plainc...
解决delphi的 dbgrid在读取access文本型字段显示TWideMemoField的问题标签:targe 窗体 自定义 ase 读取 data 字段 解决 proc 本文系统来源:http://www.cnblogs.com/chuangyiyuan/p/6587310.html
Delphi DBGrid右键删除行并提交至数据库.在form上添加,控件TPopupMenu,并指定右键名称:删行
2.编写删除语句:
If ADOQuery1.State in [dsEdit, dsInsert] then ADOQuery1.Post; If ADOQuery1.RecordCount <> 0 then ADOQuery1.Delete;
3.把dbgrid的PopupMenu属性,设置成刚刚添加的控件TPopupMenu。
4.编译,运行delphi 右键删除dbgrid行标签:添加 for popup 提交 delete pup 编写 数据 stat 本文...
////删除多选记录
procedure THistoryForm.DeleteButtonClick(Sender: TObject);var tempBookMark:TbookMark; i:integer;begin if dbgrid1.SelectedRows.Count <= 0 Then begin MessageBox(Handle,‘请选择您要删除的记录‘,‘提示‘,MB_OK); Exit; end;
If MessageBox(Handle,‘删除后数据将不可恢复,您确定要删除吗?‘,‘提示‘,mb_iconinformation+mb_YesNo)=IdYes Then Begin i:=0; DBGrid1.Datasource....
全选
procedure TFrameCustSelector.ToolButton1Click(Sender: TObject);
varOldCurrent: TBookmark;
beginOldCurrent := DBGrid1.DataSource.DataSet.Bookmark;DBGrid1.DataSource.DataSet.DisableControls;DBGrid1.DataSource.DataSet.First ;while not DBGrid1.DataSource.DataSet.Eof do beginDBGrid1.SelectedRows.CurrentRowSelected := true;DBGrid1.DataSource.DataSet.Next;end;DBGrid1.DataSource.DataSet.GotoBookmark(...
DBGrid1.DragMode := dmManual;//留意这个设置不要变
procedure ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
procedure TForm18.ApplicationEvents1Message(var Msg: tagMSG;var Handled: Boolean);begincase Msg.message of WM_LBUTTONDOWN: begin if Msg.hwnd = DBGrid1.Handle then begin DBGrid1.Perform(Msg.message,...
uses Excel2000,ComObj;
procedure F_Form.Button1Click(Sender: TObject);var myExcel:TExcel; Int_i,Int_j,rowCount,columnCount:Integer; ExcelId:Variant;begin try ExcelId:=CreateOleObject(‘Excel.Application‘); except on Exception do raise Exception.Create(‘无法创建报表,请确认是否安装EXCEL‘); end;
if DBGrid4.DataSource.DataSet.RecordCount<>0 then begin rowCount:=DBGrid4...
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls;
type TForm1 = class(TForm) DataSource1: TDataSource; ADOTable1: TADOTable; DBGrid1: TDBGrid; Button1: TButton; procedure DBGrid1DblClick(Sender: TObject); private { Private declarations } public { Public declarations } // v...
DBGrid1.DataSource.DataSet.RecNo; //行
列:
如果有 column 属性则column.Index; //列否则:DBGrid1.SelectedIndex; //列
创建时间:2020.03.12 更新时间:
来源:https://www.cnblogs.com/guorongtao/p/12466995.html
Delphi DBGrid 获取焦点几行和几列标签:size logs log com dataset data phi sel style 本文系统来源:https://www.cnblogs.com/guorongtao/p/12466995.html