1

I'm wondering how I can select the specific WebID value in my DBGrid for the record which is double clicked? For example if they clicked anywhere in the row of WebID 2, I have a variable to store the number 2. I have a SQLQuery, then a DataSetProvider then a ClientDataSet supplying my DBGrid through a DataSource. Let me know if you need anymore information. Thank you!

Toby Fox
  • 105
  • 4
  • 11
  • 1
    You read the value from the table or query field. The record pointer is positioned on whatever row is selected in the grid. IOW, if the DBGrid is connected to the ClientDataSet, you'd read the ClientDataSet field that contains `WebID` to get it's value. – Ken White Jan 23 '15 at 18:46
  • And how exactly would I read this? CDS.fields[0]? WebId is column 0. Thank you – Toby Fox Jan 23 '15 at 18:55
  • 1
    `CDS.FieldByName('WebID').AsInteger` (replace `WebID` with the actual name of your column, of course). You really should read through the tutorials on database programming in the documentation; this is really basic stuff that the tutorials explain. – Ken White Jan 23 '15 at 18:57

1 Answers1

1

If you know the column number inside the grid (lets say it is in a variable or constant colNumWebID) and WebID is an integer field, you can easily access the current value with

currentWebID := DBGrid1.Columns[colNumWebID].Field.AsInteger;
Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130