unit DBLookupComboBoxEx;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DB, DBCtrls;
type
TDBLookupComboBoxEx =
class(TDBLookupComboBox)
private
FAllowClear: boolean;
procedure ClearField;
protected
procedure KeyDown(
var Key: Word; Shift: TShiftState);
override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
override;
public
published
property AllowClear: boolean
read FAllowClear
write FAllowClear
default False;
end;
procedure Register;
implementation
procedure TDBLookupComboBoxEx.ClearField;
begin
if FAllowClear
and CanModify
then
begin
DataSource.Edit;
Field.Clear;
end;
end;
procedure TDBLookupComboBoxEx.KeyDown(
var Key: Word; Shift: TShiftState);
begin
inherited KeyDown(Key, Shift);
if (Key = VK_DELETE)
then ClearField;
end;
procedure TDBLookupComboBoxEx.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (Button = mbRight)
then ClearField;
inherited MouseDown(Button, Shift, X, Y);
end;
procedure Register;
begin
RegisterComponents('
DBAddOns', [TDBLookupComboBoxEx]);
end;
end.