List Combo Boxes GroupBox Radio Boxes in Delphi
GroupBox here is a small code excerpt used to get the text of the selected radio button of a group: var I: Integer; T: String; begin
for I:=0 to GroupBox1.ControlCount -1 do if (GroupBox1.Controls[I] as TRadioButton).checked then T := (GroupBox1.Controls[I] as TRadioButton).Caption; ... ... .. ComboBox Component code below will trap the ENTER key and add the current Text to the list if it's not found there (the list can not be empty): procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: char); begin // if the user press the // Enter key if Key = chr(13) then with ComboBox3 do if (Text <> '') and (Items.IndexOf(Text) < 0) then Items.add(Text); end; Note: first two(2) properties determine the main connection, as usual. The other three(3) properties determine the secondary source(ListSource), the field used for the join(KeyField), and the information to display(ListField). | RadioGroup Components using the radio group is generally easier than using the group box, since the various items are part of a list, as in a list box. This is how you can get the text of the selected item: Text := RadioGroup1.Items [RadioGroup1.ItemIndex]; ListBox Component The selection of an item in a list box uses the Items and ItemIndex properties as in the code shown above for the RadioGroup control. Result := List.Items [List.ItemIndex]; for a multiple-selection list box, see the code below: var selItems: string; nItem: Integer; begin
selItems := ''; for nItem := 0 to ListBox1.Items.Count-1 do if ListBox1.selected [nItem] then selItems := selItems + ListBox1.Items[nItem] + ''; ... ..
DBLookupComboBox If the list of values is extracted from another dataset, then you should use the specific DBLookupListBox or DBLookupComboBox components. Here is a list of the relevant values: DataField = 'cust_no' DataSource = DataSourceOrders KeyField = 'Cust_no' ListField = 'company, cust_no' ListSOurce = DataSourceCustomer DropDownWidth = 30 |

