tdbgrid
Contrary to most other Delphi data-aware controls, the DBGrid component has many nice features and is more powerful than you might think.
与大多数其他Delphi数据感知控件相反,DBGrid组件具有许多不错的功能,并且功能超出您的想象。
Below are ways in which you can get the most out of the TDBGrid Delphi component, separated into categories.
下面是使您充分利用TDBGrid Delphi组件(分为几类)的方法。
基础 ( The Basics )
You can make the Enter key work like the Tab key in a DBGrid, which also allows Shift+Enter to function like it would if Tab+Enter were used.
您可以使Enter键像 DBGrid中的Tab键一样工作 ,它还允许Shift + Enter像使用Tab + Enter时一样起作用。
See how to fix DBGrid column widths automatically (at run-time) to remove the unfilled space at the right edge of the grid. It will automatically adjust the column width to fit even the widest entry.
了解如何自动 (在运行时) 修复DBGrid列宽以删除网格右边缘的未填充空间。 它将自动调整列宽以适合最宽的条目。
You can also enhance the functionality of a TDBgrid component using colors (coloring rows, columns, cells - depending on a field value).
您还可以使用颜色 (为行,列,单元格着色-取决于字段值)来增强TDBgrid组件的功能 。
Follow this tutorial to see how to show the contents of a MEMO field (textual BLOB) in a TDBGrid, plus how to enable editing MEMO's.
遵循本教程,以了解如何在TDBGrid中显示MEMO字段 (文本BLOB) 的内容 ,以及如何启用编辑MEMO的内容。
其他一些漂亮的教程 ( Some Other Nifty Tutorials )
When the DBGrid's Options property includes dgRowSelect and dgMultiSelect, users can select multiple rows within the grid.
当DBGrid的Options属性包括dgRowSelect和dgMultiSelect时 ,用户可以在网格中选择多个行 。
One of the most natural and easiest ways to let your users sort a column is to have them click the column title. Follow our guide on how to sort records in Delphi DBGrid for all the information you need to make this happen.
让您的用户对列进行排序的最自然,最简单的方法之一就是让他们单击列标题。 遵循我们的指南, 了解如何在Delphi DBGrid中对记录进行排序,以获取实现此记录所需的所有信息。
See how to retrieve, display, and edit Microsoft Excel spreadsheets with ADO (dbGO) and Delphi to learn how to connect to Excel, retrieve the sheet data, and enable that data to be edited using the DBGrid. You'll also find a list of most common errors that might show while in the process, plus how to deal with them.
了解如何使用ADO(dbGO)和Delphi 检索,显示和编辑Microsoft Excel电子表格 ,以了解如何连接到Excel,检索工作表数据以及使该数据能够使用DBGrid进行编辑。 您还将找到在此过程中可能会显示的最常见错误的列表,以及如何处理它们。
进阶指南 ( Advanced Guides )
Need to highlight the row behind the mouse cursor in a DBGrid? We've got you covered. It makes reading the data much easier when the whole row is lit up. Find out how to select (make active) and highlight (change the color, font, etc.) a row in a DBGrid as the mouse moves around the grid.
是否需要突出显示DBGrid中鼠标光标后面的行? 我们已经覆盖了你 。 当整行点亮时,它使读取数据变得更加容易。 了解如何在鼠标围绕网格移动时选择(激活)并突出显示(更改颜色,字体等)在DBGrid中的一行。
Here's how to place just about any Delphi control (visual component) into a cell of a DGBrid, such as checkboxes (using a TChekBox control).
这是将几乎任何Delphi控件 (可视组件)放置到DGBrid的单元格中的方法,例如复选框 (使用TChekBox控件)。
翻译自: https://www.thoughtco.com/using-the-tdbgrid-component-1058370
tdbgrid