Jump to content

How to add many spaces among UniLabel's caption?


55143681

Recommended Posts

5 hours ago, 55143681 said:

but, actually,that can only display one space,"abc 123",

why?

This is normal behavior for the display of whitespaces is to compress them into a single one, which is then displayed.

There are two exceptions from that:

1. Using <pre> tag:

    UniLabel1 -> TextConversion = txtHTML

    UniLabel1 -> <pre>Caption = abc              123</pre>

2. Using CSS:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniLabel1.JSInterface.JSConfig('style', ['white-space: pre']);
end;

UniLabel1 -> TextConversion = txtRegular

UniLabel1 -> Caption = abc              123

Link to comment
Share on other sites

20 hours ago, Sherzod said:

This is normal behavior for the display of whitespaces is to compress them into a single one, which is then displayed.

There are two exceptions from that:

1. Using <pre> tag:

    UniLabel1 -> TextConversion = txtHTML

    UniLabel1 -> <pre>Caption = abc              123</pre>

2. Using CSS:


procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniLabel1.JSInterface.JSConfig('style', ['white-space: pre']);
end;

UniLabel1 -> TextConversion = txtRegular

UniLabel1 -> Caption = abc              123

1:should be

UniLabel1 -> TextConversion = txtHTML;

    UniLabel1 -> Caption ="<pre> abc              123</pre>";

Link to comment
Share on other sites

1 hour ago, 55143681 said:

Can you tell me how to write the sentence with cbuilder?


 UniLabel1.JSInterface.JSConfig('style', ['white-space: pre']);

The answer is:

void __fastcall TMainForm::UniFormCreate(TObject *Sender)
{
UniLabel1->JSInterface->JSConfig("style","\"white-space:pre\"");
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::UniBitBtn1Click(TObject *Sender)
{
UniLabel1->TextConversion=txtRegular;
UniLabel1->Caption="abc    123";

}
//---------------------------------------------------------------------------
 

Link to comment
Share on other sites

@55143681

Hello

This also works fine :

 

procedure TMainForm.UniButton1Click(Sender: TObject);
//=====================
 const MySpace='&nbsp;';
//=====================

begin

  UniLabel1.TextConversion:=txtHTML;
  UniLabel1.Caption:='A' + MySpace +'B';

// for  others components (UniMemo1,  UniTreeView1,  ....)
// you don'nt have to specify TextConversion (there are already in txtHTML)

end;

Cheers.

 

Edit :  for many space :  UniLabel1.caption :=  'A' + MySpace + MySpace + MySpace + MySpace + MySpace + 'B';

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...