Recent

Author Topic: TDBGrid get value from row  (Read 15645 times)

catosp

  • New member
  • *
  • Posts: 9
TDBGrid get value from row
« on: September 11, 2011, 10:10:20 am »
Hello everybody ! :)

I have a huge problem wich sound like this :

I have a database and aTDBGrid with 3 columns. Each columns have 10 records and the problem is how can i get the value from row 3 wich is situated in column 2 ?

Please help me ...

Thanks !

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
Re: TDBGrid get value from row
« Reply #1 on: September 11, 2011, 12:39:37 pm »
   Two ways, one can read the value of the selected record:
    data_set.field_name.value (or data_set.fields[index_of_fields].value)
 or
   if not(DBGrid.DataSource.DataSet.Fields[index_of_fields].Value = NULL) then
            some_var:= DBGrid.DataSource.DataSet.Fields[index_of_fields].Value;
« Last Edit: September 11, 2011, 12:43:17 pm by exdatis »

catosp

  • New member
  • *
  • Posts: 9
Re: TDBGrid get value from row
« Reply #2 on: September 11, 2011, 12:43:42 pm »
Yes...but i don't wanna read the value of a selected row. I wanna read a custom cell from DBGrid. Example Column 2 and row 5 even the selected row is from column 2 and row 2.

Sorry for my bad english.

m.vincent

  • New Member
  • *
  • Posts: 17
Re: TDBGrid get value from row
« Reply #3 on: September 19, 2011, 04:22:22 pm »
Catosp,

I think the code posted by exdatis should get you started to doing what you want to do. All the info is there.

However, I think you are going about this the wrong way. Embedding numbers to rows and columns of a dataset is asking for trouble in the future.  A better way would be to construct a SQL query which returns the value you want independent of your GUI elements.

Kind regards,

Mike

 

TinyPortal © 2005-2018