Alan Colburn wrote: > I've got a form with a bunch of RadioGroups. I created an array of > RadioGroups to make it easier to write code to work with the group. I've > also got a ComboBox in which the user can choose whether s/he would like to > display 2, 3, or 4 items (i.e., select "2" and all the RadioGroups will have > 2 and 1 as their items; select "3" and they'll all display 3, 2, and 1). > > The ComboBox OnChange event begins by clearing all the RadioGroups, and then > adding items back (with the items added depending upon what the user > selected in the ComboBox): > > for i := 1 to 19 do > begin > gRadioArray[i].Items.Clear; > with cbxPerformanceLevels do > //add items here, depending on what user selected > end; > > The code works fine, and it's simple. The problem is that it's slow. On my > machine I can watch each RadioGroup be cleared, one at a time, before items > are added in. > > Do you have any ideas about a faster way to do this?
I'd suggest using RadioGroup.Items.BeginUpdate and RadioGroup.Items.EndUpdate around your loop to prevent the group repainting itself each time you add or remove an item. You might also try building your list of new items in a TStringList in memory and then add it all at once to the RadioGroup using RadioGroup.Items.Assign(StringList); HTH Stephen Posey [EMAIL PROTECTED] _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

