简体   繁体   中英

Is there a way to get a cell value from the selected row in DBGrid? (Delphi)

First of all, I'm pretty new to Delphi.

I have a DBGrid connected to a DataSource and filled up with data from an SQL server. What I want to achieve is that when I press a button, it brings up a new window with comboboxes/editboxes, all filled up with the previously selected (in DBGrid ) row's data and modify them and execute an UPDATE query.

In order to do that, I need the primary key value of the selected record, so my little program would know which row should it display and update.

My question is, how can I get a specific cell value (in this case, an id) of a selected record from a DBGrid ?

If you know the column for the ID field you can inspect its Field property. The Fields Value will contain the current ID.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM