1 (edited by samtorn 2024-03-25 10:53:04)

Topic: change code to get other cell value from selected row

what to change in this code to get other cell value from selected row in datagrid instead then the ID .

ShowMessage ('ID record:' + IntToStr (TOTAL_Hours.TableGrid1.dbItemID)); // Get selected record id

Re: change code to get other cell value from selected row

There are a number of ways to achieve this.
One of the simplest is to display in your message the contents of a column that you specify in your script depending on the row you have clicked on (see the script in the attachment).  In this example, clicking on a row show the 'city' field.
Also you can be totally flexible and show the contents of any cell (any column, any row);  see the commented out code in the script.
Maybe this helps.
Derek.

Post's attachments

Attachment icon show cell in message box.zip 446.44 kb, 21 downloads since 2024-03-25 

Re: change code to get other cell value from selected row

derek wrote:

There are a number of ways to achieve this.
One of the simplest is to display in your message the contents of a column that you specify in your script depending on the row you have clicked on (see the script in the attachment).  In this example, clicking on a row show the 'city' field.
Also you can be totally flexible and show the contents of any cell (any column, any row);  see the commented out code in the script.
Maybe this helps.
Derek.


Thank you very much i found a way and solved it ,  here is the code i have made

var
  selectedRow: Integer;
  valueNeeded: String;
begin

  selectedRow := TOTAL_Hours.TableGrid1.SelectedRow;

  valueNeeded := TOTAL_Hours.TableGrid1.Cells[3, selectedRow]; 


 TOTAL_Hours.Label11.Caption := (valueNeeded);