unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, Grids, ValEdit;

type
  TMainForm = class(TForm)
    Panel1: TPanel;
    btnClose: TBitBtn;
    ValueListEditor1: TValueListEditor;
    procedure ValueListEditor1DblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btnCloseClick(Sender: TObject);
  private

  public
	 procedure Koniec();
  end;

var
  MainForm: TMainForm;

implementation
{$R *.dfm}

procedure TMainForm.btnCloseClick(Sender: TObject);
begin
	Koniec();
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
	// wstawiać od tyłu
	ValueListEditor1.InsertRow('4 miejsce' , 'nie nagradzane', false);
	ValueListEditor1.InsertRow('3 miejsce' , '10 000', false);
	ValueListEditor1.InsertRow('2 miejsce' , '50 000', false);
	ValueListEditor1.InsertRow('1 miejsce' , '1 000 000', false);
end;

procedure TMainForm.Koniec();
begin
	if Application.MessageBox('Koniec pracy', 'Uwaga', MB_ICONINFORMATION or MB_YESNO) = mrYes then
	begin
		Close();
   end;
end;


procedure TMainForm.ValueListEditor1DblClick(Sender: TObject);
var
	Key   : String;
   Value : String;
	ARow  : Integer;
	ACol  : Integer;

begin
	Key   := '';
   Value := '';
	ARow  := 0;
	ACol  := 0;

   if ValueListEditor1.RowCount >= 0 then
   begin
   	ARow  := ValueListEditor1.Row;
		Key   := ValueListEditor1.Cells[0, ARow];
		Value := ValueListEditor1.Cells[1, ARow];

      ShowMessage('Key  : ' + Key + #10#13 + 'Value: ' + Value);
   end;
end;

end.
