SetCharAttr Method

[Top]  [Chapter]  [Previous]  [Next]

Applies to

IWPParInterface                                                workswithseltext

Declaration

procedure SetCharAttr(Index: Integer; CharAttr: Integer);

Description

This methods sets the character attribute index of one character in the paragraph.

This example use EnumParagraphs to set one character attribute (Courier New, 10.5 pt, Green) to the complete text.

 

IWPAttrInterface help = wpdllInt1.AttrHelper;

help.Clear();

help.SetFontface("Courier New");

help.SetColor(wpdllInt1.ToRGB(Color.Green));

help.SetFontSize(10.5F);

// Trigger OnEnumParOrStyle

wpdllInt1.CurrMemo.EnumParagraphs(true,help.CharAttrIndex);

wpdllInt1.CurrMemo.ReformatAll(true,true);

 

 

 

This event handler executed for all paragraphs:

private void wpdllInt1_OnEnumParOrStyle(

 object Sender,

 bool IsControlPar,

 int StartPos,

 int Count,

 WPDynamic.IWPParInterface ParText,

 WPDynamic.IWPAttrInterface ParAttr,

 int EventParam, //= int parameter passed to EnumParagraphs

 ref bool Abort)

{

 for (int i = 0; i < ParText.CharCount; i++)

  ParText.SetCharAttr(i, EventParam);

}

 

Note: The example above is intended to only demonstrate the technique, to set the character attribute of the complete text we recommend to used code like this:

IWPAttrInterface SelAttr = wpdllInt1.CurrSelAttr;

wpdllInt1.TextCursor.SelectAll();

SelAttr.SetFontface("Courier New");

SelAttr.SetColor(wpdllInt1.ToRGB(Color.Green));

SelAttr.SetFontSize(10.5F);

wpdllInt1.TextCursor.HideSelection();

Category

Character Attributes


[idh_iwpparinterface_setcharattr_.htm]    Copyright © 2007 by WPCubed GmbH