Add a TextBox in a RV in the middle of a line

General TRichView support forum. Please post your questions here
Post Reply
sylvainl
Posts: 26
Joined: Thu Oct 09, 2014 10:18 am

Add a TextBox in a RV in the middle of a line

Post by sylvainl »

I would like to be able to add a textbox in a Richview in the middle of a line. Currently, when I try, it breaks my line (visually adding a CR ?).

The code I use:

Code: Select all

procedure TForm1.ReplacePlaceHolderItemByATextBox(RVData: TCustomRVData; var ARVE: TRichViewEdit; i: integer {place holder item No});
var
  TextBox: TRVTextBoxItemInfo;
  id: integer;
begin

  TextBox := TRVTextBoxItemInfo.Create(RVData);
  TextBox.Document.Clear;
  TextBox.Document.AddTextBlockNLA(ListeDesChamps.GetValue(TAG_SignatureCaseACocher),RVData.GetItem(i).StyleNo,RVData.GetItem(i).ParaNo);
  // position
  TextBox.BoxPosition.HorizontalAnchor := rvhanCharacter;
  TextBox.BoxPosition.VerticalAnchor := rvvanLine;
  TextBox.BoxPosition.PositionInText := rvpitBelowText;
  // size
  TextBox.BoxProperties.WidthType := rvbwtAbsolute;
  TextBox.BoxProperties.HeightType := rvbhtAbsolute;
  TextBox.BoxProperties.Width := 300;
  TextBox.BoxProperties.Height := 10;
  TextBox.BoxProperties.VAlign := tlBottom;
  // removing border and spacing around
  TextBox.BoxProperties.Border.Style := rvbNone;//Single;
  TextBox.BoxProperties.Border.BorderOffsets.SetAll(0);
  TextBox.BoxProperties.Border.Width := 0;
  TextBox.BoxProperties.Background.BorderOffsets.SetAll(0);
  TextBox.ParaNo := RVData.GetItem(i).ParaNo;
  TextBox.BR := False;
  TextBox.ClearLeft := False;
  TextBox.ClearRight := False;

  // adding text box
  RVData.AddItem('', TextBox);

  id := RVData.Items.IndexOfObject(TextBox);
  RVData.Items.Exchange(id , i);  // to place my text box at a specific place (instead of my placeholder item)
  RVData.DeleteItems(id,1);  // I delete my place holder item
  
  ARVE.Format;
 end;
I thought maybe it were an align issue (ClearLeft or ClearRight on my item doesn't help).
Does someone have an idea?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Add a TextBox in a RV in the middle of a line

Post by Sergey Tkachenko »

TextBox.ParaNo := -1 before calling AddItem. AddItem will adjust it.
Assignments of BR, ClearLeft, ClearRight are not needed, they are used only for items that start paragraphs.
sylvainl
Posts: 26
Joined: Thu Oct 09, 2014 10:18 am

Re: Add a TextBox in a RV in the middle of a line

Post by sylvainl »

Thank you, Sergey. It works !
Post Reply