Home > Archive > Delphi > March 2006 > Button Captions
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Andrew Cuthbert 2006-03-14, 9:57 pm |
| Hey all,
I'm designing a program that will ask general knowledge questions - the
questions themselves, and 3 possible answers are stored in an Access
database table, that is linked to Delphi through an ADO connection.
I've created a Questions Form, that has a DB Edit box (to show the
questions), and 3 buttons. Each will show a possible answer, the user will
click on the one they think is right, then the question and answer boxes
change to show the next questions eg:
______ ______ _____
|_____| |______| |_____|
I plan for the caption of these buttons to change to read one of the
possible answers for a question, then once the user selects an answer by
clicking an answer button, the button's caption should change to read a
possible answer for the next question.
I know I can edit a button's caption using code like Button1.caption:= ...,
but I don't know how to get to the button to look up a string from a
database table, and use that as it's caption.
Also, after the button's caption shows the question number, I need to know
how to make the button look up the caption for the next question in turn
afterwards.
I'm using Delphi 4 at school - does anyone think they can help?
--
Andy Cuthbert
http://andrewcuthbert.mysite.wanadoo-members.co.uk/
www.join-me.co.uk
| |
| J French 2006-03-14, 9:57 pm |
| On Tue, 14 Mar 2006 20:59:00 -0000, "Andrew Cuthbert"
<Andrew.Cuthbert@hollesley02.FSnet.co.uk> wrote:
>Hey all,
>
>I'm designing a program that will ask general knowledge questions - the
>questions themselves, and 3 possible answers are stored in an Access
>database table, that is linked to Delphi through an ADO connection.
>
>I've created a Questions Form, that has a DB Edit box (to show the
>questions), and 3 buttons. Each will show a possible answer, the user will
>click on the one they think is right, then the question and answer boxes
>change to show the next questions eg:
>
>______ ______ _____
>|_____| |______| |_____|
>
> I plan for the caption of these buttons to change to read one of the
>possible answers for a question, then once the user selects an answer by
>clicking an answer button, the button's caption should change to read a
>possible answer for the next question.
>
>I know I can edit a button's caption using code like Button1.caption:= ...,
>but I don't know how to get to the button to look up a string from a
>database table, and use that as it's caption.
>
>Also, after the button's caption shows the question number, I need to know
>how to make the button look up the caption for the next question in turn
>afterwards.
>
>I'm using Delphi 4 at school - does anyone think they can help?
Personally I would ditch the Access database
- use a Text File and a TStringList
| |
| Marc Rohloff 2006-03-15, 7:57 am |
|
Andrew Cuthbert wrote:
> I know I can edit a button's caption using code like Button1.caption:= ...,
> but I don't know how to get to the button to look up a string from a
> database table, and use that as it's caption.
You should be able to do something like:
Button1.Caption := tblQuestions.FieldByName['Question1'].AsString;
An alternative is to double click the dataset and add fields in the
editor in which case you can do:
Button1.Caption := tblQuestions_Question1.AsString;
> Also, after the button's caption shows the question number, I need to know
> how to make the button look up the caption for the next question in turn
> afterwards.
You could do this when the button is clicked since you are already
going to the next question. The alternative is to write an event
handler for your dataset's (table or query) 'AfterScroll' event.
--
Marc
|
|
|
|
|