1.options是对这个表格的操作的相关属性,比如dgEditing设置为false那么你就不能对其进行编辑了. 2.把options中的dgrowselect设置为true.然后在 procedure TForm1.DBGrid1DblClick(Sender: TObject); begin showmessage(adoquery1.Fields[0].AsString); end;
Value Meaning dgEditing The user can edit data using the grid. dgEditing is ignored if Options includes dgRowSelect. dgAlwaysShowEditor The grid is always in edit mode. That is, the user does not have to press Enter or F2 before editing the contents of a cell. dgAlwaysShowEditor does nothing unless dgEditing is also included in Options. dgAlwaysShowEditor is ignored if Options includes dgRowSelect. dgTitles Titles appear at the top of the columns in the grid. dgIndicator A small pointer appears in the first column to indicate which row is current. dgColumnResize Columns that are bound to fields can be resized or moved. dgColLines Lines appear between columns in the grid. dgRowLines Lines appear between the rows of the grid. dgTabs The user can navigate through the grid using the Tab and Shift+Tab keys. dgRowSelect The user can select an entire row, as well as selecting individual cells. If Options includes dgRowSelect, dgEditing and dgAlwaysShowEditor are ignored. dgAlwaysShowSelection The selected cell displays the focus rectangle even when the grid does not have focus. dgConfirmDelete A message box appears, asking for confirmation, when the user types Ctrl+Delete to delete a row in the grid. dgCancelOnExit When the user exits the grid from an inserted record to which the user made no modifications, the inserted record is not posted to the dataset. This prevents the inadvertent posting of empty records. dgMultiSelect More than one row in the grid can be selected at a time.
2.把options中的dgrowselect设置为true.然后在
procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
showmessage(adoquery1.Fields[0].AsString);
end;
dgEditing The user can edit data using the grid. dgEditing is ignored if Options includes dgRowSelect.
dgAlwaysShowEditor The grid is always in edit mode. That is, the user does not have to press Enter or F2 before editing the contents of a cell. dgAlwaysShowEditor does nothing unless dgEditing is also included in Options. dgAlwaysShowEditor is ignored if Options includes dgRowSelect.
dgTitles Titles appear at the top of the columns in the grid.
dgIndicator A small pointer appears in the first column to indicate which row is current.
dgColumnResize Columns that are bound to fields can be resized or moved.
dgColLines Lines appear between columns in the grid.
dgRowLines Lines appear between the rows of the grid.
dgTabs The user can navigate through the grid using the Tab and Shift+Tab keys.
dgRowSelect The user can select an entire row, as well as selecting individual cells. If Options includes dgRowSelect, dgEditing and dgAlwaysShowEditor are ignored.
dgAlwaysShowSelection The selected cell displays the focus rectangle even when the grid does not have focus.
dgConfirmDelete A message box appears, asking for confirmation, when the user types Ctrl+Delete to delete a row in the grid.
dgCancelOnExit When the user exits the grid from an inserted record to which the user made no modifications, the inserted record is not posted to the dataset. This prevents the inadvertent posting of empty records.
dgMultiSelect More than one row in the grid can be selected at a time.
dgTitles 是否可以在网格顶部用displaylabel显示字段名
dgIndicator 是否显示网格左边列的字段状态提示符,当处于浏览状态时,提示符为三角,编辑状态时,提示符为I
dgColumnResize 是否可以用拖动字段格线的方式调整字段宽度
dgColLines 是否绘制网格竖线
dgRowLines 是否绘制网格横线
dgTabs 是否可以用TAB键跳转
dgRowSelect 是否选择整条记录,否是选择字段
dgAlwaysShowSelection 被选中内容是否用蓝背景标识
dgConfirmDelete 字段删除是否提示
dgCancelOnExit 退出时未确认的修改会取消
dgMultiSelect 允许多行选择
用自己的理解翻译了下,不是直译