Hi,
I am a beginner in Lazarus. I have simple testing codes to bring up a form with combo box on it. What I am trying to do is to fill the items on combo box when the form shows up.
The problem is when the form shows up, the combo box is empty.
The calling the form is as follows:
procedure TForm1.Button1Click(Sender: TObject);
begin
AddNewEntry.ShowModal;
end;
The form with combo box is as follows:
unit AddEntry;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TAddNewEntry }
TAddNewEntry = class(TForm)
Category: TComboBox;
procedure OnCreate(Sender: TObject);
private
public
end;
var
AddNewEntry: TAddNewEntry;
implementation
{$R *.lfm}
procedure TAddNewEntry.OnCreate(Sender: TObject);
begin
Category.Items.Clear;
Category.Items.Add('Item1');
Category.Items.Add('Item2');
end;
end.
Why is the combo box is empty?
I tried to put the combo box filling codes inside "OnShow" and "OnActivate", but the result is the same.
I attached this simple testing codes here.