Solved

output a click onto a panel

Posted on 2004-03-30
10
156 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
[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
  • 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
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 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
 
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

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

705 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