I have this issue I can't seem to figure out what is going on.
I have a listbox on a form filled with "Items" list
When you just click on an item in the list I can send the value to a label, I can also show the value in a MSGbox
But, If I double-click on it and try to evaluate the value using IF ELSE, it returns nothing.
According to WIKi and other docs the list box returns a string list.
And since I am getting the string from the list item, WHY is this happening?
CODE:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
lbCMD: TLabel;
lstCMD: TListBox;
procedure Button1Click(Sender: TObject);
procedure lstCMDClick(Sender: TObject);
procedure lstCMDDblClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.lstCMDClick(Sender: TObject);
begin
lbCMD.Caption:=lstCMD.Items[lstCMD.ItemIndex];
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(lstCMD.Items[lstCMD.ItemIndex]);
end;
procedure TForm1.lstCMDDblClick(Sender: TObject);
begin
if lstCMD.Items[lstCMD.ItemIndex] = 'assoc' Then
showmessage('yes')
else
showmessage('no');
end;
end.
DEMO PROJECT (that doesn't work)