c++builderc++builder-10.2-tokyo

Any way to extract values from TDBGrid?


if(TPoints->Filter == String(Lat1) + String(" < Latitude AND ")+
                  String("Latitude< ")+ String(Lat2) + String(" AND ")+
                  String(Lon2) + String("< Longitude AND ")+
                  String("Longitude < ") + String(Lon2));
else{
    ShowMessage("Invalid Boundries");
}

First time using data access and control components. TPoints is a TADOTable, results are listed in a TDBGrid. If possible I need to do more than just showing the filtered results (filtering code above) from database. How to go to a specific row or maybe cell and play with it?


Solution

  • To move to a specific record, you have to set the RecNo property of TADOTable.

    In a database, moving to a specific field of a record (AKA a cell) does not mean much, unless you want to edit the content of it. The Edit() method of TADOTable can put a record into edit mode, but I'm not sure how you can choose a cell programmatically. It also depends on your design. Normally, the user can start the edit mode by double-clicking on a cell, which takes care of everything automatically. But, if you want to change the data without the user typing it, a TADOQuery and SQL statement is a much better choice.

    Be more specific about what you want to happen on the screen and the user's interaction. That way, we can help you better.

    By the way, you don't extract data from the grid itself, you extract it from a DataSet (TADOQuery or TADOTable) that the grid is attached to.