Multiline TCheckBox

Hi there,

Is there a possibility to create TCheckBox with multiline caption? I have additional TLabel acting as a second line. It's better than nothing but really sucks. I have tried something like Caption := 'Line1'#13#10'Line2';  but didn't work.

Regards,
albi
albireo77Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wimmeyvaertCommented:
Maybe you will found here what your are looking for :
http://www.sparksoftcomponents.com/
0
wimmeyvaertCommented:
0
wimmeyvaertCommented:
Also, if yo ua re using delphi5, a extra cd is shipped with LMD-Tools component-package on it.
If you install these components, then you have a multiline Checkbox also (tab LMD Std)
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

mikelittlewoodCommented:
If you want to have a little fun and do this yourself without a third party component, try this little sneaky method.

http://delphi.about.com/c/ht/00/07/How_Create_Word_Wrapped0962933210.htm

Works for buttons, but Im assuming it should work for a TCheckbox too  

:o)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wimmeyvaertCommented:
Indeed, this is xorking too.
Delphi is such a great tool. Really Object Oriented.

Only disadvantage is that you still have 2 Components on your form (a TCheckBox and a TLabel in it).

I guess this is what albireo77 was trying to avoid.

But it can be a workaround if you don't want to make use of 3rd party components.
0
mikelittlewoodCommented:
btw, I presume you are not using Delphi 7 then as wordwrapping comes as standard for TCheckbox, TButton etc
0
Eddie ShipmanAll-around developerCommented:
This makes all the checkboxes you drop on a form have a Wordwrap property, hence, multi-line:
{Note, the property won't show in the Object Inspector but it will be avail}

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TCheckBox = class(StdCtrls.TCheckBox)
  private
    FWordWrap: Boolean;
    procedure SetWordWrap(const Value: Boolean);
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  public
    constructor Create(AOwner: TComponent); override;
  published
    property WordWrap: Boolean read FWordWrap write SetWordWrap default False;
  end;

  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TCheckBox }

constructor TCheckBox.Create(AOwner: TComponent);
begin
  inherited;
  FWordWrap := True;
end;

procedure TCheckBox.CreateParams(var Params: TCreateParams);
begin
  inherited;
  if FWordWrap then
    Params.Style := Params.Style or BS_MULTILINE;
end;

procedure TCheckBox.SetWordWrap(const Value: Boolean);
begin
  if FWordWrap <> Value then
  begin
    FWordWrap := Value;
    RecreateWnd;
  end;
end;

end.


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.