Re: TStringGrid and CR/LF




Bart wrote:
> Hi,
>
> I'm trying to load a table of strings (not a database, so I don't
> need/want data-aware components) into a TStringGrid. Some of the
> strings however contain CR/LF sequences and are not displaeyd in the
> stringgrid as I would like it to be.
> When I put the stringgrid in edit-mode, pressing the Enter-key also
> soed not give me a new line in the cell I'm in.
>
> Okay, so I want the individual cells of the stringgrid to behave as
> some sort of multiline-edit (no need for individual scrollbars per
> cell though <g>).
> Is this possible at all?
> If so, how can I achieve this.
>
> I'm using Delphi 3 Pro (for quite some time now, but this is the first
> time I'm using a StringGrid in any of my applications).
>
> Hope someone can help.
>
> Bart
> --
> Bart Broersma
> broersma.juda_ANTISPAM_@xxxxxxxxxx
> (ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)

Firstly implement ownerdraw by coding to paint the display in the
OnDrawCell event handler. You can then use the DrawText() API to draw
multiline rows in the stringgrid within the cell rectangle.

Secondly when you double-click in the cell, create a TMemo instance and
position it over the cell which has been clicked on, and load it from
the cell. When the editing entry is finished the load the text back
from the TMemo to the TStringGrid and free the TMemo.

Alan Lloyd

.



Relevant Pages

  • Re: Grid cell draw
    ... >CustomDrawCell, but when to adjust the width for the column, ... So you would be better doing the cell width adjustment outside the OnDrawCell. ... Do it when you load the stringgrid with text (measuring the widths of all ...
    (comp.lang.pascal.delphi.misc)
  • Re: Stringgrid problem, pls help me
    ... I gave coding to edit directly into the stringgrid and a word wrap ... edit directly into the stringgrid cell without using and edit control ...
    (comp.lang.pascal.delphi.misc)
  • Re: drag and drop on stringgrid
    ... yuda wrote: ... Is it possible to drag data from one cell in stringgrid and drop it ...
    (borland.public.delphi.database.ado)
  • Re: "select all in a stringgrid cell
    ... >Basically I want to programatically go to a cell but I ... >want to then select all (or highlight the entire string,) ready for ... All you need to do is set the Options for the StringGrid as follows. ... You can do this at design time in the Object Inspector, ...
    (alt.comp.lang.borland-delphi)
  • Re: Loading those huge CSVs.
    ... > There's this data viewer form with a stringGrid on it. ... an instace of this form is created & the grid loaded up with ... use a secondary thread started at the time the form is created to load the ... you can use a number of tricks to cut down on memory use and load time. ...
    (borland.public.delphi.language.objectpascal)