Board index » delphi » Set text properties in new record blob

Set text properties in new record blob

I am trying to set the contents of a blob OnNewRecord to a
string of text - ok so far... but how do I set it to bold?

I have tried the following:

Var rtfTemp:TDBRichedit;
Begin
*  rtfTemp.Lines.Add('Recovery Prospects  : ');
  with rtfTemp do begin
    selstart := 0;
    sellength := 21;
    selattributes.size := 10;
    selattributes.Name := 'Arial';
    selattributes.Style := [fsBold];
    // set 'after' string to normal
    selstart := 22;
    sellength:=0;
    selattributes.Style := [];
  end;
  dm.InsRepsRecoveryProspects.Assign(rtfTemp);

I get an AV when I run this at the line marked *. On other forms
I have done something similar but the component could be dropped
on the form with visible=false. Since this is a datamodule I
cannot do this so I need to know how to declare the richedit
non-visually and use it properly.

Pat Bell

 

Re:Set text properties in new record blob


Quote
>Var rtfTemp:TDBRichedit;
>Begin
>*  rtfTemp.Lines.Add('Recovery Prospects  : ');
>I get an AV when I run this at the line marked *. On other forms
>I have done something similar but the component could be dropped

You need to create the component before you can use it

Var rtfTemp:TDBRichedit;
rtfTemp := TDBRichedit.create(self)

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Set text properties in new record blob


Quote
In article <3942a658.44533019@floyd>, Brian Bushay TeamB wrote:

> You need to create the component before you can use it

> Var rtfTemp:TDBRichedit;
> rtfTemp := TDBRichedit.create(self)

I now get an AV if I try to access any of the rtf properties such as
lines or selstart. Do I have to initialise it in any way?

procedure TDM.InsRepsNewRecord(DataSet: TDataSet);
Var rtfTemp:Tdbrichedit;
begin
  rtfTemp:=Tdbrichedit.create(self);
  rtfTemp.Lines.Add('Recovery Prospects  : '); // AV
  rtfTemp.text:='Recovery Prospects  : ';  // OK
  rtfTemp.selstart := 0; //AV

Pat Bell

Re:Set text properties in new record blob


Quote
>I now get an AV if I try to access any of the rtf properties such as
>lines or selstart. Do I have to initialise it in any way?

Try setting the Parent property of the TdbRichedit

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads