unit MyCMBOX;
interface
uses
SysUtils, Classes, Controls, StdCtrls;
Type
TMyCBBox = class(TComboBox)
private
FOldStyle : TComboBoxStyle;
FEnterText : Boolean;
procedure SetEnterText(const Value: Boolean);
protected
procedure SetStyle(Value: TComboBoxStyle);
override;
public
constructor Create(AOwner: TComponent);
override;
published
property EnterText : Boolean read FEnterText write SetEnterText;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Standard', [TMyCBBox]);
end;
{ TMyCBBox }
constructor TMyCBBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEnterText := Style <> csDropDownList;
end;
procedure TMyCBBox.SetEnterText(const Value: Boolean);
begin
if FEnterText <> Value then
begin
FEnterText := Value;
if FEnterText then
begin
Style := FOldStyle;
end
else
begin
if Style <> csDropDownList then
FOldStyle := Style;
Style := csDropDownList;
end;
end;
end;
procedure TMyCBBox.SetStyle(Value: TComboBoxStyle);
begin
inherited SetStyle(Value);
FEnterText := Style <> csDropDownList;
end;
end.