[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Setting up a button to Control a data grid

Posted on 2005-04-11
5
Medium Priority
?
141 Views
Last Modified: 2010-04-05
I am trying to creat a button that on click event will be to move to records beging with certian letters in the Data Grid

Example

2 Fields

Artist
Title


When you push the Button with the label A it will move the grid to all the A;s in the data grid

The data base is access using ADO connection string





0
Comment
Question by:jfgrayiii
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13755112
is your dataset sorted?

yes -> use the locate-method of the dataset
  buttonclickevent
   dataset.locate(fieldname,TButton(sender).Caption,[loPartial]);

no -> use the filterproperty of the dataset
  buttonclickevent
    dataset.filter('fieldname like '+quotedstr(TButton(sender).Caption+'%'));  //replace % with * for accessDB
    dataset.filtered := true;

just from head, means not tested and typos possible

meikl ;-)
0
 

Author Comment

by:jfgrayiii
ID: 13755894
Is caption where I will put the value I want filtered

example show me only  Filed named Artist that starts with 'A'

0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13756392
here's a quick example i wrote for you

put 2 buttons on the form
set button 1's caption to 'A'
set button 2's caption to 'B'
use the same OnClick event for each button and do this

procedure TForm1.AtoZButtonClick(Sender: TObject);
    var
        s: string;
    begin
        s := (Sender as TButton).Caption;
        Table1.FindNearest([S]);
    end;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13756441
hmm, as far as i know findnearest requires an index

>Is caption where I will put the value I want filtered
yes, this caption was meant of the botton, as in TheRealLoki sample

meikl ;-)
0
 
LVL 11

Accepted Solution

by:
pcsentinel earned 2000 total points
ID: 13760151
You can do it without a button.

Add a TEdit Control called Edit1 to the form.

On the OnChange event of the TEdit put

Dataset.Locate('Artist',Edit1.Text,[loCaseInsensitive, loPartialKey]);

regards
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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 a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

834 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