Ver Mensaje Individual
  #6  
Antiguo 27-01-2011
ezear84 ezear84 is offline
Registrado
NULL
 
Registrado: ene 2011
Posts: 2
Reputación: 0
ezear84 Va por buen camino
Revivo el post para añadir un metodo sencillo de insertar caracteres con formato:

Para añadir lineas con formato no se puede utilizar

Código Delphi [-]
RichEdit.lines.add(`linea de texto 1`);

ya que añade texto plano.
Se debe hacer del siguiente modo (y se puede crear un procedimiento para hacerlo mas sencillo):

Código Delphi [-]
{poner un richEdit1 en el formulario y un boton en el evento onclick agregar:}
 with richEdit1 do
 begin
   //si se quiere añadir la linea a lo ultimo poner:
   SelStart := GetTextLen;
   //de lo contratio usar: SelStart := 0;
 
   //añadir una linea
   SelText := 'Primera linea' + #13#10;
 
   //añadir otra linea
   SelText := 'texto con formato en richedit' + #13#10;
 
   //comenzar a cambiar el texto
   SelAttributes.Size := 13;
 
   //negrita + rojo
   SelAttributes.Style := [fsBold];
   SelAttributes.Color := clRed;
   SelText := 'Buena';
 
   //cambiamos color para el proximo texto
   SelAttributes.Color := clWindowText;
   SelText := ' Programación ';
 
   //italicas + azul
   SelAttributes.Style := [fsItalic];
   SelAttributes.Color := clBlue;
   SelText := 'en Delphi';
 
   //nueva linea
   SelText := #13#10;
 
   //texto normal otra vez
   SelAttributes.Size := 8;
   SelAttributes.Color := clGreen;
   SelText := 'Ahora podes hacer un procedimiento...';
 end;
Responder Con Cita