Solved

output a click onto a panel

Posted on 2004-03-30
10
152 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

14 Experts available now in Live!

Get 1:1 Help Now