Lazarus: Multiline StringGrid Cells
Question by Guest | 2016-02-13 at 09:44
The content of some cells of my StringGrid are so long, that the width of the corresponding column is not sufficient. This leads to the behavior, that the content is just truncated.
However, instead of that, I would rather like to have a line break so that the content of the cell is just displayed in multiple lines in that case.
But how can I achieve this? I have not found any property such as WordWrap, WordBreak and MultiLine in the TStringGrid component.
Related Topics
Delphi: Multiline Caption for TLabel (at Run Time and Design Time)
Tutorial | 1 Comment
PHP: Sending an E-Mail
Tutorial | 0 Comments
Lazarus: Jump with Enter Key into next Row of StringGrid
Question | 1 Answer
Lazarus: Only make specific columns editable in StringGrid
Question | 1 Answer
HTML: Preassign HTML Form with Data
Tutorial | 0 Comments
Lazarus: Display dots if StringGrid Cell Content is too long
Question | 1 Answer
HTML: Table - Merge Cells
Question | 1 Answer
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Your StringGrid has the event OnPrepareCanvas. This event is called for each cell and you can use it to control the TextStyle of the cell.
In your case, this can look like that:
Here, we are setting SingleLine to FALSE and WordBreak to TRUE which is making the text displayed with line break in the corresponding cell.
As you can see, there are also parameters for the column and row provided. We can use them to apply different properties for different cells. For example:
In this example, we check whether it is the second column and we are changing the behavior only in that case. With this, there is only a line break within the second column while the other comments are showing the default behavior.
2016-02-13 at 11:22