How to use different font styles and icon in stringgrid Firemonkey cell

It seems that there is not much information on this topic, so hopefully someone can give some suggestions.

I would like to change the color and style of various parts of the text in a stringgrid cell.

Example: 02/20/2011 - title of the document

Can I also show the icon in a stringgrid cell?

+4
source share
1 answer

Indeed, you can display icons or bitmaps in a grid of strings, the Monkey Styler blog provides an example of how to display cells in an FMX grid.

http://monkeystyler.com/blog/entry/firemonkey-grid-basics-custom-cells-and-columns

Thinking about the other part of your question, you will need to create a style to display text in different fonts, but FMX has no components with extended text or HTML rendering (I’m sure that the latter will come, the first one I’m not sure about receiving for a while! ) You will need to have a text component in the style for each different font size / style, etc., you will need to name the text elements (using the binding properties or stylename) and handle the text content settings using the code in the ongetvalue and onsetvalue of the event (I think , you could also use the onapplystyle event) to display some text in bold and some not.

The event handler will then use either a binding that is easier to set, but - in my experience - is buggy;

mycell.binding['boldtext']:='sometext'; 

Or find a style element using stylename using findstyleresource;

 tempobj:=mycell.findstyleresource('boldtext'); if tempobj is ttext then ttext(tempobj).text='sometext'; 

Sorry for any bad coding style, but you get the general idea (hopefully) if you set autoisize to true for style ttext components and align them until you get - basically - what you need. The only problem is that the resulting text does not look completely seamless, because the automation and alignment on the left does not give you the same space between the fonts that you get with a richtext or HTML display. You should be able to tinker with the indentation (giving it a negative number for the left pad so you can remove the extra space), but you have to live with the fact that this is not entirely perfect compared to the right hints and font alignment.

0
source

Source: https://habr.com/ru/post/1399983/


All Articles