Automatic change of Row Height with WordWrap ?
Posted: Sunday 9th May 2021 9:15am
Hi.
In my search for a suitable way to display HTML rich text I discovered that a nice solution for my project would be to ‘abuse’ a GridView control for that purpose. The formatting possibilities of the grid itself and it’s cells, combined with the Rich Text displayed in those cells are manifold.
I have created a small project to demonstrate this.
It uses a GridView with only one column to display differently formatted text in each cell. Works fine for me, but there is one problem that – if solved – would make it really ideal: how to fit text in each cell. To do this, I have to set each cell’s height so that the text will be visible as it should. That can of course be done, but the intention is to use this to display help text or instructions in different languages. As we know, some languages need more words to explain things. And that will or can ruin the layout.
The solution would be that Rows[x].Height changes automatically when any cell in that row ‘WordWraps’ it’s content.
Either I don’t find it, or it’s not possible (yet). I found a topic about this here:
https://gambas-user.narkive.com/CSTpFWV ... e-question
where Benoit Minisini writes:
“In Gambas 3, WordWrap is a property attached to the cell. And to adjust the
width of a row or a column, you must set its height (or width) to "-1". But,
if I remember well, it is not implemented in gb.gtk yet.”
However, that post is 10 years old ….
It didn’t work when I tried. Has a solution been found since then?
In my search for a suitable way to display HTML rich text I discovered that a nice solution for my project would be to ‘abuse’ a GridView control for that purpose. The formatting possibilities of the grid itself and it’s cells, combined with the Rich Text displayed in those cells are manifold.
I have created a small project to demonstrate this.
It uses a GridView with only one column to display differently formatted text in each cell. Works fine for me, but there is one problem that – if solved – would make it really ideal: how to fit text in each cell. To do this, I have to set each cell’s height so that the text will be visible as it should. That can of course be done, but the intention is to use this to display help text or instructions in different languages. As we know, some languages need more words to explain things. And that will or can ruin the layout.
The solution would be that Rows[x].Height changes automatically when any cell in that row ‘WordWraps’ it’s content.
Either I don’t find it, or it’s not possible (yet). I found a topic about this here:
https://gambas-user.narkive.com/CSTpFWV ... e-question
where Benoit Minisini writes:
“In Gambas 3, WordWrap is a property attached to the cell. And to adjust the
width of a row or a column, you must set its height (or width) to "-1". But,
if I remember well, it is not implemented in gb.gtk yet.”
However, that post is 10 years old ….
It didn’t work when I tried. Has a solution been found since then?