• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

output a click onto a panel

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
zgeorge_2
Asked:
zgeorge_2
  • 6
  • 4
1 Solution
 
shaneholmesCommented:
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
 
zgeorge_2Author Commented:
where does that go onto the pln

or under each button
thank you
0
 
zgeorge_2Author Commented:
what if the buttons are created automatically
how will i add  that to each of them

shaneholmes is that you ?
0
Industry Leaders: 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!

 
shaneholmesCommented:
I have no idea what you are asking in your last two questions - no idea at all,

Shane
0
 
zgeorge_2Author Commented:
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
 
shaneholmesCommented:
"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
 
zgeorge_2Author Commented:
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
 
shaneholmesCommented:
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
 
shaneholmesCommented:
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
 
shaneholmesCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now