?
Solved

output a click onto a panel

Posted on 2004-03-30
10
Medium Priority
?
158 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

771 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