Insert other visual components in Delphi DBGrid

Source: Internet
Author: User

Delphi provides a powerful DBGrid component to facilitate database application design. But if we just use the DBGrid component, each gain focus (Grid) is just a simple text edit box, which makes it inconvenient for users to enter data. Delphi also provides a number of other data components to facilitate user input, such as dbcombobox,dbcheckbox and other components, but these components are not dbgrid powerful. Can Delphi, like Visual FoxPro, get the focus grid in DBGrid to be other visual data components for the convenience of the user? We can actually do this by inserting other visual components into the DBGrid.

The internal mechanism of Delphi processing for DBGrid is to float a component--dbedit component on the grid. The grid in which you enter the data is actually a floating dbedit component, and other places that don't get focus are just images. So, inserting other visual components in DBGrid is a visual component floating on the grid. So any component, including from simple Dbcheckbox to complex dialog boxes, can be inserted into the DBGrid. Here's how to insert a Dbcombobox component in a DBGrid, using the same approach to insert other components.

1, a new project in Delphi 4.0.

2. Drag the Data Access palette on the DataSource, Table,data controls component Board Dbgrid,dbcombobox four components to the FORM1.

3, set the properties of each component as follows:

/tr>
properties set-sik
caption insert Spinedit Component sample
dataset table1
tab Le1 dbdemos
tablename teacher. DBF active true
data Source datasource1
dbcombobox1 datafield SEX
datasource datasource1
visi ble strings Items. " > male | female

Note: I used the teacher.dbf here, that reflects the staff's gender, can only be "male" or "female".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.