DBGrid1

A、ShowMessage(IntToStr(Column.Index)); 
  B、ShowMessage(IntToStr(dbgrid1.SelectedField.Index));

1、得到当前格子中的内容:
DBGrid1.Fields[DBGrid1.SelectedIndex].DisplayText;
把DBGrid1.SelectedIndex改为你所希望引用的字段就可以了,如第3个字段。

DBGrid1.Fields[3].DisplayText;

2、双击单元格触发不同事件

procedure TMainFrm.DBGrid1DblClick(sender:TObject);

begin

     if dbgrid1.fields[dbgrid1.selectedIndex].FiledName=‘GNO‘ then begin   //   dbgrid1.selectedIndex ---选中单元格列

         //响应事件

     end;

     if dbgrid1.fields[dbgrid1.selectedIndex].FiledName=‘PSNNAME‘ then begin

         //响应事件
     end;

     if dbgrid1.fields[dbgrid1.selectedIndex].FiledName=‘RCSJ‘ then begin

         //响应事件

     end;

end;
时间: 2024-08-26 13:24:17

DBGrid1的相关文章

ClientDataSet中动态添加计算字段并用计算字段显示记录的UpdateStatus

ClientDataSet中每条记录都有UpdateStatus=(usUnmodified, usModified, usInserted, usDeleted)记录该条数据是修改的,删除的,还是新增的等.有时候我们只想看修改的或新增的或删除的就可能用到这一属性.下图用计算字段显示UpdateStatus状态. ********************************************************************************************

delphi 更改DBGrid 颜色技巧

1.根据条件更改某一单元格的颜色 [delphi] view plaincopy procedure TMainFrm.First_DGDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if DM.FirstListStatus.AsString='生产' then begin First_DG.Canvas.Fon

http://bbs.csdn.net/topics/340046630 dbgrid怎么获取当前记录值

这根grid无关,当你选中一条记录时,数据集就定位到这条数据上了,你只需要读取数据集中的数据就行了 对我有用[0] 丢个板砖[0] 引用 | 举报| 管理 hongss hongss 本版等级: #5 得分:10回复于: 2010-05-17 19:41:36 你要的是鼠标点击那里的当前值? 比如 Delphi/Pascal code ? 1 DBGrid1.SelectedField.DataSet.FieldValues['Date']; 对我有用[0] 丢个板砖[0] 引用 | 举报| 管

《世界杯彩票竞猜系统》设计报告

目录 1 文档介绍    4 1.1 文档目的    4 1.2 文档范围    4 1.3 读者对象    4 1.4 参考文献    5 1.5 术语与缩写解释    5 2 系统环境说明    6 3 需求分析    7 3.1 功能需求分析    7 3.2 非功能需求分析    7 4 数据库的命名规则    8 5 概念结构设计    9 6 逻辑结构设计    9 7 物理结构设计    11 7.1 表汇总    11 7.2 表VS    11 7.3 表team    12

Delphi中根据分类数据生成树形结构的最优方法

一. 引言:    TreeView控件适合于表示具有多层次关系的数据.它以简洁的界面,表现形式清晰.形象,操作简单而深受用户喜爱.而且用它可以实现ListView.ListBox所无法实现的很多功能,因而受到广大程序员的青睐.    树形结构在Windows环境中被普遍应用,但在数据库开发中面对层次多.结构复杂的数据,如何快速构造树形目录并实现导航呢?    二. 实现关键技术:    在Delphi提供的控件中包含了TreeView控件,但树的具体形成还需要用户编写代码.即它的列表项要在程序

在DBGrid增加一列CheckBox(而非DBCheckBox)

自:http://rabbitfox.blog.sohu.com/33264033.html http://community.csdn.net/Expert/topic/5342/5342920.xml?temp=.9525568 问:如何使dbgrid增加一列类似checkbox的控件,可以用鼠标来选择该行是否被选中,可以多选 最好的思路还是要在数据表里增加一个布尔字段,然后用DBCheckBox与它关联,而不是CheckBox.(至于在DBGrid里嵌入DBCheckBox的方法,可以参考

数据集和非数据感知控件使用

1 unit frmMainUnit; 2 3 interface 4 5 uses 6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7 jpeg, // 这里是一些手工的引用 8 Dialogs, DB, ADODB, StdCtrls, DBCtrls, Mask, Grids, DBGrids, Buttons, Menus, 9 ExtCtrls, ExtDlgs; 10 11 ty

(转)CheckBox inside a DBGrid

This is the first article, in the series of articles named "Adding components to a DBGrid". The idea is to show how to place just about any Delphi control (visual component) into a cell of a DGBrid. If you are unfamiliar with the idea, please fi

ADO SQL delete 日期条件参数

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids; type TForm1 = class(TForm) Button1: TButton; ADOQuery1: TADOQuery; Memo1: TMemo; DBGrid1: TDBGrid; Dat