?
Solved

DBgrid in delphi

Posted on 2003-02-25
6
Medium Priority
?
361 Views
Last Modified: 2010-04-04
Hello All,
I have a dbgrid connected to a datasource which points at a table.  I am trying to implement an edit field in which as you type the first few letters of a name will move the current table pointer to a record which begins with those letters, while still keeping the entire table in the dbgrid.  The only way I have done this so far is to use sql which only displays the results and not the entire table, can someone help?
Also I wish to sort the information in my DBgrid by a Lastname field, and not the key field, how is this done?

Thanks in advance,
Justin
0
Comment
Question by:jonzer12
[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
6 Comments
 
LVL 3

Expert Comment

by:ILE
ID: 8019983
Exactly what u wont :))

on form is one  one edit componet and dbgrit,table and data source


procedure TForm1.FormActivate(Sender: TObject);

begin
  Table1.DatabaseName := 'DBDemos';
  Table1.TableName := 'Customer.db';
  Table1.Active := True;
  Table1.IndexName := 'ByCompany';
end;

procedure TForm1.Edit1Change(Sender: TObject);

begin
    Table1.FindNearest([Edit1.Text]);
end;



this is example taken from delphi
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 8023742
? ILE thats just uncomplete

findnearest works only with indexed fields

i would advice to use the locate-method for non-indexed fields, like


procedure TForm1.Edit1Change(Sender: TObject);
begin
  if not Table1.locate('LastName',Edit1.Text,[loCaseInsensitive, loPartialKey]) then
    ShowMessage('No Match');
 
end;

but personally better i think is to use a filter like

procedure TForm1.Edit1Change(Sender: TObject);
begin
  Table1.DisableControls; //no updates to the controls
  try
    Table1.Filtered := False;
    Table1.Filter := 'LastName = '+quotedstr(Edit1.Text+'*');
    Table1.Filtered := True;
  finally
    Table1.EnableControls; //Show result
  end;
end;

meikl ;-)

locate('LastName',Edit1.Text,[loCaseInsensitive, loPartialKey]) then
    ShowMessage('No Match');
 
end;

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8023749
ignore the last three lines above :-))
0
 

Expert Comment

by:CleanupPing
ID: 9317065
jonzer12:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 10

Expert Comment

by:kacor
ID: 9969965
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept kretzschmar's answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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