Freeing buttons created in a dynamic array

From: GB Blanchard (1122_at_1122noexiste.net)
Date: 03/16/04


Date: Tue, 16 Mar 2004 19:16:18 GMT

I'm creating some buttons on a panel like this:

{...}
SetLength(BtnArray,Length(CharString));

  for Col := 0 to ColCount - 1 do
  for Row := 0 to RowCount - 1 do
  begin
    Btn := TButton.Create(Self);
    Btn.Parent := pnBtnArray;
    Btn.SetBounds(Col * (BtnWidth + 1), Row * (BtnHeight + 1),
BtnWidth, BtnHeight);
    if Row = 0 then
      Btn.Caption := CharString[Col +1]
    else
      Btn.Caption := CharString[(Col +1) + ColCount];
    Btn.OnClick := btSendKeyClick;
    BtnArray[Col] := Btn;
  end;

{...}

 Each button has one character as a caption and the user can change
which character set he wants to use at any time. Therefore, he may
start with 10 characters on 10 buttons, and later decide to choose
3 characters on 3 buttons.

 The problem is that the extra 7 buttons and characters will still
be shown on the first row of the new 3 button selection because I
haven't been able to figure out how to free the buttons of the
first selection. Any advice will be greatly appreciated.

-- 
Brad Blanchard