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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to Retrieve data from TDBGrid in DBedit boxes

Status
Not open for further replies.

pkakkar

Programmer
Apr 24, 2008
15
0
0
FI
Hello,

I have a form which as DBGrid and can see the records from customer database. Now I have another form say Form2 which has 5 DBEdit components which is connected to the database customer number, first name, last name, phone and address.

Now I want to edit the records in DBGrid. I want that If I click on any record in DBGrid its corresponding data is entered in Form2's DBedit boxes and i can edit the data and save it.

Can someone help as to how to make the corresponding data entered in DBEdit boxes...

I dont know which property of DBGrid to use when i write this line

Form2.DBEdit1.text :=Form1.DBGrid1.someproperty(first_name);
I am not sure if this line is also correct.
regards
Pooja
 
If the dbeditboxes and dbgrid point to the same table, give them the same tdatasource

Steven
 
Yes I have done that. But I want if I select any row in DBGrid, the values in the respective columns should come in DBEdit boxes.

so for that i have to write something like
Form2.DBEdit1.Text:=DBGrid1.SelectedRows.(something.,..I dont know what???)
or may be some other property....which i dont know..

so if I have 5 columns in DBGrid say Cust No, first name, lastname, address and phone number...on selecting that particular row , its corresponding value should come in DBEdit1.Text, DBEdit2.Text and so on..

regards
Pooja
 
Are you using datamodules? Datamodules are the standard way to share common non-visual components.
[ul square]
[li]In this case place your query and datasource on a TDataModule.[/li]
[li]Let form1 and form2 use the DataModule unit[/li]
[li]Use the OnCellClick event of the dbGrid to bring up form2, you can use Form2.ShowModal [/li]
[/ul]

Steven
 
if your dbedits are linked to the same data source and fields as the grid then the edits will show the selected record in the grid without any code from you.

Aaron
 
no need to reply.,..its done'

i have used fields[index]property

cheers
Pooja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top