Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBGrid Index

Status
Not open for further replies.

rhysmeister

Programmer
May 29, 2003
54
GB
I can use SelectedIndex to return the selected column index value in a DBGrid. Is there a similar function which will return the row index value?
 
Code:
ParamByName('SelectedParam').AsInteger := DBGrid1.SelectedRows.Count + 1;

Always returns '1' for some reason.
 
what is it you are trying to do? If it's a dbgrid there's a datasource behind it. Whatever record you have selected in the dbgrid you have also selected in the datasource. You should know the name of the field that fills that cell in the grid so you can just do:

ParamByName('SelectedParam').AsInteger := datasourceOfDbGrid.FieldByName('SomeField').Asinteger



Leslie
 
OK, from a DBGrid the user clicks on a column and the ID from that record row is put into a SQL query and another form appears with just that records details on it. All this work fine except the correct ID field value is not selected.
 
did the example I show above not do that? It should have. What is the source of the DBGrid?



Leslie
 
SelectedRows determine the number of rows in the grid that are selected (property MultiSelect in Options of DBGrid).

I use InfoPower dbgrid. It has property: GetActiveRow that return a 0 based row number of selected row in dbgrid.

Giovanni Caramia
 
This code did the trick. I probably wasn't clear enough in my explaining. Thanks.

Code:
ParamByName('SelectedParam').AsString := DBGrid1.SelectedField.AsString;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top