How to auto fill a label caption with a character. It has to depend on the width and the font used.

How to auto fill a label caption with a character. It has to depend on the width and the font used.
In the past I only used monospaced fonts so I could use simple algorithm using the string length.

Comments

  1. Cool, you're welcome. Textwidth, textheight and even TextOut are all there and available via TCanvas on VCL controls. They come in handy sometimes. :-)

    ReplyDelete
  2. If you want to add dots, do you mean an ellipsis ("...")? TLabel has an EllipsisPosition property so that if the text is too long, it will automatically truncate and add an ellipsis. You could, if you want, just set a really long caption and let it add one itself without worrying about measuring and having the right number of characters.

    ReplyDelete
  3. Wouldn't a grid with edit controls be nicer? The cells would give you the visual guidance, you get to do a "copy" of all content if you want to, or to flush the text to the right, if so desired?  It also becomes trivial to add or remove options dynamically?

    ReplyDelete

Post a Comment