[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Multiline TCheckBox

Posted on 2006-03-28
7
Medium Priority
?
820 Views
Last Modified: 2010-04-05
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
0
Comment
Question by:albireo77
  • 4
  • 2
7 Comments
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16309549
Maybe you will found here what your are looking for :
http://www.sparksoftcomponents.com/
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16309563
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16309580
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 15

Accepted Solution

by:
mikelittlewood earned 375 total points
ID: 16309793
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
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 16309995
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
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 16310008
btw, I presume you are not using Delphi 7 then as wordwrapping comes as standard for TCheckbox, TButton etc
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 16311974
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question