Solved

output a click onto a panel

Posted on 2004-03-30
10
153 Views
Last Modified: 2010-04-05
basically access database is connected to my application and now i need to


i have 5 buttons on the pnlMain and i want to have it like this:

when you press one of the buttons(they are located in the table Items )

so i will output Item name and it's item descriptio located in the table Item but called desc

can anybody help how could i out put that onto a panel  
0
Comment
Question by:zgeorge_2
  • 6
  • 4
10 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10720654
Place the Item name as the caption of each button, then assign this OnClick event to each button.


procedure TForm1.ItemButtonClick(Sender: TObject);
begin
 Table1.Open;
 Table1.Locate(TButton(Sender).Caption, [Item],[]);
 ShowMessage(Table1.FieldByName('Description').asString;
 Table1.Close;
end;

Shane

0
 

Author Comment

by:zgeorge_2
ID: 10728500
where does that go onto the pln

or under each button
thank you
0
 

Author Comment

by:zgeorge_2
ID: 10728542
what if the buttons are created automatically
how will i add  that to each of them

shaneholmes is that you ?
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10728555
I have no idea what you are asking in your last two questions - no idea at all,

Shane
0
 

Author Comment

by:zgeorge_2
ID: 10728764
nevermind i am so sorry for that my friend got my account password and started writing some nonsense

well the buttons are being generated by Delphi for  access
so where should i put this then in the program

thank you
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Expert Comment

by:shaneholmes
ID: 10728855
"well the buttons are being generated by Delphi for  access
so where should i put this then in the program"

again - have no idea what your are asking?

Try writing more than one or two sentences and explain what you want?

Shane
0
 

Author Comment

by:zgeorge_2
ID: 10728897
have 5 buttonsn generating itself form thee acces database  on the pnlMain and i want to have it like this:

when you press one of the buttons(they are located in the table Items )

so i will output Item name and it's item descriptio located in the table Item but called desc

onto  TfrmMain.Image2Click

how could i make that happen

thank you
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10729033
OK, you have 5 buttons  generated during runtime from an Acces database onto the Main panel.

When you press one of the buttons created it will output Item name and it's item description.

Is that what you want?


Is the caption of the button the item name (taken from database)?

Please post the code where you create the buttons.

Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10729039
ARe you creating a POS system.

Why dont you zip up your code & access database and send it to me and i will take a better look.

Shane  (holmesshane AT charter DOT net)

0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 500 total points
ID: 10729159
If you have already generated your buttons from the database then my code above will do what you want

here it is again

procedure TForm1.ItemButtonClick(Sender: TObject);
begin
 Table1.Open;
 Table1.Locate(TButton(Sender).Caption, [Item],[]);
 ShowMessage(Table1.FieldByName('Description').asString;
 Table1.Close;
end;


Here is my code to generate buttons

X:= 10; Y:= 10; OffSet:= 10;
table1.Open;
while not table1.eof do
begin
 btn:= TButton.Create(pnlMain);
 btn.Parent:= pnlMain;
 btn.Left:= X;
 btn.Top:= Y;
 btn.Caption:= table1.FieldByName('Item').asString;
 btn.OnClick:= DoClick;
 X:= X + btn.Width + Offset;
 table1.next
end;

here is the OnClick event to assign to each button


procedure DoCLick(Sender: TObject);
begin
 Table1.Open;
 Table1.Locate(TButton(Sender).Caption, [Item],[]);
  ShowMessage(Table1.FieldByName('Description').asString;   //this will show the description
 Table1.Close;
end;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now