Forum > Database

[SOLVED] Index selection via a TComboBox

(1/1)

1HuntnMan:
I've seen this design in other apps such as MyDBF Studio.  This is the way I designed a TComboBox for selecting/changing the index for a particular table. This app is designed with dBase v7, see below the Case statement allowing the user to select a sort/index stored in the Items/TStrings. Compiles but when I run it, it's not selecting what I selected or rather the Case statement I wrote is not right. When I test, it's not executing the Case selections, it's dropping into the ELSE. Should I be using DBListBox or combo instead?

procedure TFrmCntksMain.CmboBxIndexBySelect(Sender: TObject);
begin
  Case CmboBxIndexBy.SelText of
    'Contact ID#':DbfContacts.IndexName:= 'CONTACTID';
    'Name(L,F,M)':DbfContacts.IndexName:= 'CNTKNAME';
    'Category':DbfContacts.IndexName:= 'CATEGORY';
    'State/Province':DbfContacts.IndexName:= 'STATPROV';
    'Country':DbfContacts.IndexName:= 'CNTRYCODE';
  else
    WriteLn('Index value not selected...');
  end;
  DbfContacts.Refresh;
end;

wp:
Combobox.SelText? This is the text currently highlighted in the combobox's edit field in the csDropDown style. Be aware that items may be selected in the combobox, but necessarily highlighted! Or what if the combobox is switched to csDropDownList style?

You probably mean the Combobox.Text which behaves more in the way you are expecting.

1HuntnMan:
Okay WP, thanks.  I'll rework this a bit from your suggestion after I mop the kitchen! My better half is a slave driver! LoL

1HuntnMan:
Ok WP,
  That works perfectly...

cdbc:
Hi
Have you considered "TComboBox.ItemIndex"?!?
Regards Benny

Navigation

[0] Message Index

Go to full version