Solved

TDBGRID ROWS

Posted on 2004-09-06
7
381 Views
Last Modified: 2010-04-05
Hi all

I want to  move through all rows of DBGrid(TDBGRID)  to find a record that matches my search criteria ,then if I found the row I want --> I want to select it and show it if it's hidden .

How can I do that??


Thanks

0
Comment
Question by:Balshe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 11988474
you can use

dbgrid.datasource.dataset.locate(fieldname,value,[locaseinsensitive,lopartialkey]);
0
 
LVL 1

Author Comment

by:Balshe
ID: 11988515
That was quick:)

 dbgrid.datasource.dataset.locate(fieldname,value,[locaseinsensitive,lopartialkey]); -->this solves the find issue  
 
how about selecting the row??



0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 11988562
call dbgrid.SelectedRows.CurrentRowSelected := True; after the locate
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 75 total points
ID: 11988574
and then to show the focus simply call DbGrid.setfocus
0
 
LVL 11

Expert Comment

by:calinutz
ID: 11988590
If you want to scroll through the Grid... searching for the field that matches your criteria you could do a slow search, using FindNext. If you use that then you will see the Grid values scrolling and stopping at your desired value.

Something like:
var
pk:string;
...

// suppose the field that is primary key is on the first position in the grid
Q1.Active:=false;
Q1.Active:=true;
Q1.FindLast;
//here remember the last record value of the primary key
pk:=DBGrid1.Fields[0].AsString;
Q1.FindFirst;

repeat
if (DBGrid1.Fields[0].AsString<>pk) and (criteria is not fullfilled) then Q1.findNext;
until (criteria is fullfilled) or (DBGrid1.Fields[0].AsString=pk);

This will select the record that fullfills the criteria you requested


This works slow on large datasets, so I would only use it on small ones
0
 
LVL 1

Author Comment

by:Balshe
ID: 11988830
thanks
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 11988841
Glad to have helped you :)

F68 ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question