Board index » delphi » Please Help With Combo Box and Edit Box Display

Please Help With Combo Box and Edit Box Display

Quote
>Hello People.

>I am currently writing my second only program and have a problem with a combo
>box and it's
>relationship with an edit box.

>I want users to be able to chose an item from a list... (for example A, B, C,
>D, E, or F)
>I would then like the price of the item to come up in an edit box.
>(for example edit box 1)

>so if items cost ?1.00 for item A then I would like ?1.00 in the edit box if
>A was chosen
>in the drop down list.

>similarly if item B was ?2.00 then I would like ?2.00 in the edit box should
>B be chosen
>in the drop down list.

>Any Help would be really appreciated

Where is the price coming from?  Is it in a Database?  Is it in your code?  

********************************
Michael Glatz              
glatzfa...@aol.com
mgl...@briefcase.com
Accept that some days you're the pigeon,
some days you're the statue.

 

Re:Please Help With Combo Box and Edit Box Display


In article <371c9405.27088...@news.demon.co.uk>, vince_gledh...@bigfoot.com

Quote
(Vince Gledhill) writes:
>I want users to be able to chose an item from a list... (for example A, B, C,
>D, E, or F)
>I would then like the price of the item to come up in an edit box.
>(for example edit box 1)

Put the values in a TStringList and the choose the value from the TStringList
with the ComboBox.ItemIndex. Do this in the ComboBoxOnChange event as :-

procedure TForm1.ComboBox1Change(Sender: TObject);
var
  SL : TStringList;
begin
  SL := TStringList.Create;
  with SL do begin
    Add('1.00');
    Add('2.00');
    Add('3.00');
    Add('4.00');
    Add('5.00');
    Add('6.00');
  end;
  Edit1.Text := SL[ComboBox1.ItemIndex];  // selection line
  SL.Free;
end;

Rather better programming would be to put the TStringList creatio in the
FormCreate event handler, and free it in FormClose. Then you would just have
the selection line in the ComboBoxOnChange event.

Alan Lloyd
alangll...@aol.com

Re:Please Help With Combo Box and Edit Box Display


Hello People.

I am currently writing my second only program and have a problem with a combo box and it's
relationship with an edit box.

I want users to be able to chose an item from a list... (for example A, B, C, D, E, or F)
I would then like the price of the item to come up in an edit box.
(for example edit box 1)

so if items cost ?1.00 for item A then I would like ?1.00 in the edit box if A was chosen
in the drop down list.

similarly if item B was ?2.00 then I would like ?2.00 in the edit box should B be chosen
in the drop down list.

Any Help would be really appreciated

TIA

vince_gledh...@bigfoot.com
PLEASE NOTE NEW ADDRESS
vince_gledh...@bigfoot.com

Cheers

Vince.

Brewpages at http://www.bigfoot.com/~vince_gledhill

Re:Please Help With Combo Box and Edit Box Display


On 19 Apr 1999 13:30:39 GMT, glatzfa...@aol.com (Glatzfamly) wrote:

Quote
>>Hello People.

>>I am currently writing my second only program and have a problem with a combo
>>box and it's
>>relationship with an edit box.

>>I want users to be able to chose an item from a list... (for example A, B, C,
>>D, E, or F)
>>I would then like the price of the item to come up in an edit box.
>>(for example edit box 1)

>>so if items cost ?1.00 for item A then I would like ?1.00 in the edit box if
>>A was chosen
>>in the drop down list.

>>similarly if item B was ?2.00 then I would like ?2.00 in the edit box should
>>B be chosen
>>in the drop down list.

>>Any Help would be really appreciated

>Where is the price coming from?  Is it in a Database?  Is it in your code?  

It will be in the code...

I was hoping (well here's the real language version) to put something like if a is chosen
then combobox1= 1.00 if B is chosen then combobox1 = 2.00 if C is chosen then combobox1 =
3.00 or whatever... and it's a list of about 11 choices altogether.
PLEASE NOTE NEW ADDRESS
vince_gledh...@bigfoot.com

Cheers

Vince.

Brewpages at http://www.bigfoot.com/~vince_gledhill

Other Threads