Is there a radiogroup component that supports ItemIndex?

I am replacing several components in one of my forms with a data-driven version, and it was a bit of a surprise when my new TDBRadioGroup was not bind to the field it was assigned to. It turns out that instead of navigating through the ItemIndex property, the "TDBRadioGroup" value is stored in TStrings, which must be filled in manually. I can understand that this would be useful in some cases, but when it is simply associated with a numeric field, something like this needs to be done:

   for i := 0 to myRadioGroup.Items.Count - 1 do
      myRadioGroup.Values.Add(intToStr(i));

      

is an unnecessary excess. Does anyone know of a data-enabled radio group component that will use ItemIndex for its value parameter?

+1


source to share


1 answer


You can specialize TDBRadioGroup and add values ​​by index, I suggest you override the procedure loaded event; override;



procedure TMyDBRadioGroup.Loaded; override;

var
  I: Integer;

begin
  inherited;
  Values.Clear;
  for i := 0 toItems.Count - 1 do
    Values.Add(intToStr(i));
end;

      

+1


source







All Articles