Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to use TCheckBox inside a TRichEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
24-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
40
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

With my colleagues, we tried to implement a checkbox object into Rich Edit.
Is that possible anyway?

Answer:

This seems not possible from within the IDE/ Object Inspector. However, if you 
create the checkbox instance dynamically (at run-time), then it works as expected.
For the following example, create a new form, drop a TRichEdit on it and create the 
checkbox in the FormCreate() event.

The button event handler code moves the RichEdit control at run-time around to 
demonstrate that the checkbox really is its child.

1   unit fMain;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7     StdCtrls, ComCtrls;
8   
9   type
10    TForm1 = class(TForm)
11      RichEdit1: TRichEdit;
12      Button1: TButton;
13      procedure Button1Click(Sender: TObject);
14      procedure FormCreate(Sender: TObject);
15    private
16      { private declarations }
17    public
18      { public declarations }
19    end;
20  
21  var
22    Form1: TForm1;
23  
24  implementation
25  
26  {$R *.DFM}
27  
28  procedure TForm1.Button1Click(Sender: TObject);
29  begin
30    RichEdit1.Left := 100 - RichEdit1.Left;
31  end;
32  
33  procedure TForm1.FormCreate(Sender: TObject);
34  var
35    cb: TCheckBox;
36  begin
37    RichEdit1.Left := 20;
38  
39    cb := TCheckBox.Create(RichEdit1);
40    // do not forget to set the
41    cb.Parent := RichEdit1;
42    cb.Left := 30;
43    cb.Top := 30;
44    cb.Caption := 'my checkbox';
45  end;
46  
47  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC