Jump to content


Photo

Wordwrap and rowheight


  • Please log in to reply
17 replies to this topic

#1 Quif

Quif
  • Members
  • 9 posts

Posted 29 August 2007 - 07:03 PM

Hi

I have a probelm, whit the wordwrap. I use a memobox to input a data (a very long sentence) and then, on a press of a button, it should appear wrapped in one the cells. The problem, is it doesn't. It's still a long sentence, that exits the boundaries of the cell. (I applied wordwrap to the column).


The secound problem is whit the autosize, it's marked as true, but nothing no cell gets longer/wider when a lot of text is entered, it just dissapears behind the boundaries of the cell.

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 29 August 2007 - 07:08 PM

Hello,

If you use TextColumn, you need to set MultiLine property to True, or you may use MemoColumn.

AutoSize is related to automatic column resize when grid is resized. If you want, you may call <GridName>.BestFitColumn(ColumnIndex) procedure after value is set in cell, or after editing is finished (OnAfterEdit event).

I hope that this helps.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Quif

Quif
  • Members
  • 9 posts

Posted 29 August 2007 - 07:30 PM

Thank you, now the wordwrap works perfectly!

The bestfitcolumn works as well, but how is it possible to automatically change the height of a row? (When lot's of lines of text are entered in a cell)?

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 29 August 2007 - 09:02 PM

Hello,

Unfortunatelly, there is no automatic support for RowHeight (but is planed). Until then, please check solution from one our user:

http://www.bergsoft....?showtopic=1237

I hope that may fit for your needs too.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 Quif

Quif
  • Members
  • 9 posts

Posted 30 August 2007 - 04:28 PM

Thank you and Der§en. I got the autoheight working, but 2 problems occurred:

1) There's a problem with the automatic vertical scrollbar. It usually becomes functional, when there are more rows, than the stringgrid can show, (for example when I add 21 rows, but the grid can only show 20). But now when some grids are much bigger than before, its still let's me use the scrollbar only after I have added 21 or more rows. (But only like 7 rows fit into the grid)

2) Printing. When I print the grid (without changing any printing settings), it prints all the rows with the default height, although they are different (autoheight).

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 31 August 2007 - 04:06 AM

Hello Quif,

Please read for answers:

1) Can you please tell me is this related to applied AutoSize code. If you may send me one small example project (source) , this will help me. Thank you.

2) NxGridPrint is currently limited to single row height, but this will be changed and improved soon.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#7 Quif

Quif
  • Members
  • 9 posts

Posted 31 August 2007 - 07:24 PM

Hi

I can't access delphi right now, but I can provide you with some images.

Sample1: Everything is ok, I have 10 rows, but they fit in the grid, so no scrollbar is needed.
Sample2: I still have 10 rows, but their full of text, and are much larger (thanks to autoheight). As you can see, they don't fit on the screen, but there is still no scrollbar.

Attached Files



#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 31 August 2007 - 09:09 PM

Hello Quif,

I think that I have spot it. Now I will fix it.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 31 August 2007 - 10:30 PM

Hello Quif,

Please add one new procedure into TNxCustomGridControl (NxCustomGridControl.pas) inside public section:

CODE
procedure TNxCustomGridControl.BestFitRow(const Index: Integer);

  function GetCellHeight(const ACol, ARow: Integer): Integer;
  var
    CellState: TCellState;
    Display: TColumnDisplay;
    CellValue: WideString;
  begin
    Display := Columns[ACol].Display;
    Display.Canvas := Canvas;
    Display.ClientRect := Rect(0, 0, Columns[ACol].Width - GridSpace[lpRight], GetRowHeight(ARow));
    
    Canvas.Font.Assign(Columns[ACol].Font);
    CellState := GetCellState(ACol, ARow);

    CellValue := GetDrawText(ACol, ARow);
    DoApplyCell(ACol, ARow, CellValue);

    Display.AsString := CellValue;
    ApplyCellFormating(ACol, ARow, CellValue, CellState);

    Result := Display.GetTextSize.cy;
  end;

var
  i, CellHeight, BestHeight: Integer;
begin
  BestHeight := 0;
  for i := 0 to Columns.Count - 1 do
  begin
    if Columns[i].Visible then
    begin
      CellHeight := GetCellHeight(i, Index);
      if CellHeight > BestHeight then BestHeight := CellHeight;
    end;
  end;
  RowHeight[Index] := BestHeight;
end;


Then, use next code for testing:

1) Add 2 columns and set WrapKind to wkWordWrap
2) On button click add next code:

CODE
  NextGrid1.AddCells([
    'This is one large text',
    'This is one even larger text wraped into several rows.',
    'Another one text with several sentences into one single cell and wraped.',
    'sdf dfggr wewerd aswwori asso sopeo ddddsw opasd gggooei asdd woqwets asfotosp ssowwotjs assda erde'
  ]);


3) And best fit row with:

CODE
  NextGrid1.BestFitRow(NextGrid1.SelectedRow);


I will do some more testings, but basically it work. This procedure will be included in official release.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#10 Quif

Quif
  • Members
  • 9 posts

Posted 01 September 2007 - 01:36 PM

Hi

Unfortunately, I don't have the source, so I'll just wait for the official release.

#11 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 01 September 2007 - 02:24 PM

Hello Quif,

New version free and with source is planed for September 3rd. This fix will be included there.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#12 Quif

Quif
  • Members
  • 9 posts

Posted 16 September 2007 - 10:07 AM

Hi, any news on the printing issue? (Different rowheight for different rows while printing)

#13 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 16 September 2007 - 10:26 AM

Hello Quif,

Unfortunatelly not. I was need urgently to finish other issue and this take some time sad.gif

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#14 Quif

Quif
  • Members
  • 9 posts

Posted 03 November 2007 - 02:04 PM

Hi again

I managed to print the grid manually, but one problem occured. All the unicode symbols show up as "?" on the paper, although they show up fine in the grid. (I use widestring to get the text from a grid cell and then use the printer.canvas.textout function). (I'm using Tahoma font, just like in the grid).

When I use the automatic printing (NxGridPrint) then the symbols show up ok.

#15 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 03 November 2007 - 02:38 PM

Hello Quif,

Do you maybe need to set printing Font to unicode Font (Tahoma, Verdana)?

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#16 Quif

Quif
  • Members
  • 9 posts

Posted 03 November 2007 - 04:01 PM

I tried both of these fonts, but neither of them works (printer.canvas.font.name:='Tahoma');

Did you use printer.canvas.textout, when printing the grid automatically?

#17 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 03 November 2007 - 05:00 PM

Hello Quif,

I am not using TextOut because it doesn't support WideStrings. I recommend using DrawTextW WINApi procedure instead.

It is similar as TextOut, but also introduce many additional flags. I even think that TextOut use DrawText WINApi procedure, but not Wide (W) version.

You may check next example how to use DrawText procedure:

CODE
procedure DrawTextRect(Canvas: TCanvas; ARect: TRect;
    Alignment: TAlignment; Text: WideString; BiDiMode: TBiDiMode = bdLeftToRight);
var
  Flags: Integer;
  StringText: string;
begin
  Flags := DT_NOPREFIX or    DT_VCENTER or DT_END_ELLIPSIS or DT_EXTERNALLEADING or DT_SINGLELINE;
  case Alignment of
    taLeftJustify: Flags := Flags or DT_LEFT;
    taRightJustify: Flags := Flags or DT_RIGHT;
    taCenter: Flags := Flags or DT_CENTER;
  end;
  if BiDiMode <> bdLeftToRight then Flags := Flags or DT_RTLREADING;
  with Canvas.Brush do
  begin
    Style := bsClear;
    case IsUnicodeSupported of
      True: DrawTextW(Canvas.Handle, PWideChar(Text), Length(Text), ARect, Flags);
      False:  begin
                StringText := Text;
                DrawText(Canvas.Handle, PAnsiChar(StringText), Length(StringText), ARect, Flags);
              end;
    end;
    Style := bsSolid;
  end;
end;


Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#18 Quif

Quif
  • Members
  • 9 posts

Posted 03 November 2007 - 06:09 PM

Hey, thanks!

I got it working!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users