Sida 1 av 2
ComboProg
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm) Button1: TButton;
Button2: TButton;
Button3: TButton;
ComboBox1: TComboBox;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations } public
{ public declarations } end;
Sida 2 av 2
var
Form1: TForm1;
implementation { TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
ComboBox1.Items.Clear;
ComboBox1.Items.Add('Niklas');
ComboBox1.Items.Add('Jesper');
ComboBox1.Items.Add('Mathias');
ComboBox1.Items.Add('Ronnie');
ComboBox1.Items.Add('Augustin');
ComboBox1.Items.Add('Hervé');
ComboBox1.Items.Add('Joakim');
ComboBox1.Items.Add('Magnus');
ComboBox1.Items.Add('Dennis');
ComboBox1.Sorted := true;
ComboBox1.ItemIndex := 0;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ComboBox1.Items.Clear;
ComboBox1.Text := '';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if ComboBox1.Items.Count > 0 then //Testar om det finns något i comboboxen begin
Label1.Caption := ComboBox1.Items[ComboBox1.ItemIndex];
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Caption := 'ComboProg';
end;
initialization {$I unit1.lrs}
end.