I would like to show both Caption and Description in the TMSFNCSearchEdit.
I saw that in the in the SLdemo TMSFNCSearchEdit2 shows both Caption and Description but I was not able to do it with simple text items.
What should I do to show both caption and description at least in the dropdown list?
This code snippet shows an initialization of a TTMSFNCSearchEdit with caption & description in items:
var
sli: TSearchListItem;
begin
TMSFNCSearchEdit1.Columns.Clear;
TMSFNCSearchEdit1.Columns.Add;
TMSFNCSearchEdit1.Items.Clear;
TMSFNCSearchEdit1.ItemHeight := 32;
sli := TMSFNCSearchEdit1.Items.Add;
sli.Captions[0] := 'caption 1';
sli.Descriptions[0] := 'description 1';
sli := TMSFNCSearchEdit1.Items.Add;
sli.Captions[0] := 'caption 2';
sli.Descriptions[0] := 'description 2';
end;
Got it.
I missed the line
TMSFNCSearchEdit1.ItemHeight := 32;
So I was able to see the caption only.
Another question, is it possible to format the text in a different way?
Instead of: Caption + LineBreak + Description, should it be possible to set Caption and Description in the same line (e.g. Caption + ' - ' + Description)?
You could use two columns for that and set caption in column 1 and description in column 2
I tried this:
procedure TForm1.FormCreate(Sender: TObject);
var
sli: TSearchListItem;
begin
TMSFNCSearchEdit1.Columns.Clear;
TMSFNCSearchEdit1.Columns.Add;
TMSFNCSearchEdit1.Columns.Add;
TMSFNCSearchEdit1.Items.Clear;
TMSFNCSearchEdit1.ItemHeight := 16;
sli := TMSFNCSearchEdit1.Items.Add;
sli.Captions[0] := 'caption 1';
sli.Captions[1] := 'description 1';
sli := TMSFNCSearchEdit1.Items.Add;
sli.Captions[0] := 'caption 2';
sli.Captions[1] := 'description 2';
end;
But I got an error when I start typing or click on the dropdownbutton.
What I am doing wrong?
When I test this code applied to a default TTMSFNCSearchEdit, I cannot see an issue here when typing in the control or opening the dropdown.
I get this error with Lazarus, both 1.6.2 and fps 3.0.0 and lazarus 1.6.4 and fps 3.0.2
See image
Anyone gets the same error on lazarus?
I have the same on Lazarus 1.8 RC5 Win32
It is on our todolist to investigate.