EhLib.Com
https://forum.ehlib.com/en/

DbComboboxEh does not have the "OnDrawItem" event
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1016
Page 1 of 2

Author:  Luciano_F [ 21 Jan 2020, 21:30 ]
Post subject:  DbComboboxEh does not have the "OnDrawItem" event

I have the following code:

but how to use it I need to have two columns in a combobox and with this event I do


procedure TForm1.Proc_ComboBoxColumnsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
Columns: TStringDynArray;
ColCount, I: Integer;
ItemText: string;
DC: HDC;
DrawRect: TRect;
Middle: Integer;
begin
ItemText := TCombobox(Control).Items[Index];
Columns := SplitString(ItemText, '|');
ColCount := Length(Columns);

if ColCount = 0 Then
Exit;

DC := TCombobox(Control).Canvas.Handle;
TCombobox(Control).Canvas.FillRect(Rect);

Middle := Rect.Left + Rect.Width div ColCount;
TCombobox(Control).Canvas.MoveTo(Middle, Rect.Top);
TCombobox(Control).Canvas.LineTo(Middle, Rect.Bottom);

For I := 2 To ColCount - 1 Do Begin
Middle := Rect.Left + ((Rect.Width div ColCount) * I);
TCombobox(Control).Canvas.MoveTo(Middle, Rect.Top);
TCombobox(Control).Canvas.LineTo(Middle, Rect.Bottom);
End;

if ColCount > 0 then begin
DrawRect := Rect;
OffsetRect(DrawRect, 1, 0);
DrawRect.Right := DrawRect.Right - ((DrawRect.Width div ColCount));
DrawTexT(DC, Columns[0], Length(Columns[0]), DrawRect, 0);
end;

For I := 1 To ColCount - 1 Do Begin
if ColCount > I then begin
DrawRect := Rect;
OffsetRect(DrawRect, 1, 0);
DrawRect.Left := DrawRect.Left + ((DrawRect.Width div ColCount) * I);
DrawTexT(DC, Columns[I], Length(Columns[I]), DrawRect, 0);
End;
End;

end;

Author:  EhLibSupport [ 23 Jan 2020, 14:20 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

Hello

DbComboboxEh doesn't support multicolumns in the dropdown box.

Why don't you use the TDBLookupComboboxEh component.
It supports several columns in the dropdown box.

Attachments:
sshot-69.png
sshot-69.png [ 52.79 KiB | Viewed 1944 times ]
sshot-70.png
sshot-70.png [ 37.71 KiB | Viewed 1944 times ]

Author:  Luciano_F [ 23 Jan 2020, 17:48 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

I don't have access to the Database for these columns, it would be system settings only.

   Another thing would be to do incremental searches for the example sentence:
  1 João da Silva
  2 Mariana Gold

I would just type "Silva" and he could find it on the list.

Author:  EhLibSupport [ 23 Jan 2020, 23:09 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

Hello

Quote:
I don't have access to the Database for these columns, it would be system settings only.

You can use ClientDataSet or MemTableEh. They can work without DataBase. Keeps all data in Memory.

Quote:
Another thing would be to do incremental searches for the example sentence:

Yes, it can filter and search in the DropDownBox

Attachment:
sshot-71.png
sshot-71.png [ 23.31 KiB | Viewed 1942 times ]


Read "Advanced Configuration of a drop-down list in Comboboxes" in the "EhLib Users Guide.doc"

Here is a Demo porject

Attachments:
2020-01-24-DBLookupComboboxEh-SimpleList2Columns.zip [2.52 KiB]
Downloaded 178 times

Author:  Luciano_F [ 23 Jan 2020, 23:45 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

Hello i can't use
TDBLookupComboboxEh
Too many tcombobox components could you place partial search on tcombobox?
Or how could I override the tcomboboxEh class for it to have this functionality.

Author:  EhLibSupport [ 24 Jan 2020, 00:14 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

Hello
The drop-down list in DbComboboxEh does not support many things.
It’s easier to write a new component than to add these features to the current DbComboboxEh.

Author:  Luciano_F [ 24 Jan 2020, 11:15 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

the "DbComboboxEh" component already has a property called "CaseInsensitiveTextSearch"
that when filling in "KeyItems" already does a search but does not do partial, I believe it would just be to change the internal method related to
"CaseInsensitiveTextSearch"

Author:  EhLibSupport [ 24 Jan 2020, 15:42 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

Hello.

Now you write only about the searching (and filtering in DbComboboxEh), and no longer consider the requirement for several columns.

What about the multi-columns proposal?

Author:  Luciano_F [ 24 Jan 2020, 17:24 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

I managed to solve the issue of several columns creating a Form with a TListView and when I need several columns I call this Form with TListView through a procedure.

However, the partial search was not successful.

Author:  Luciano_F [ 28 Jan 2020, 11:52 ]
Post subject:  Re: DbComboboxEh does not have the "OnDrawItem" event

Up

Page 1 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/