Jump to content


Photo

Equivalent of IsTextFit in NextGrid6?


  • Please log in to reply
4 replies to this topic

#1 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 31 May 2023 - 01:49 PM

Hi, Boki:

After 5 years, I am ready to try to convert a major set of NextGrid5 tables to NextGrid6 again.

 

I am doing this step by step unlike last time when I tried to discover all events and properties that did not have a readily apparent equivalent in NextGrid6. That was just overwhelming and I ended up stopping my conversion work and decided to just live with the NextGrid5 tables.

 

Right now working on Grid6.OnMouseMove

 

Is the next 3 lines correct?

 

RowNum := NxReportGridView61.GetCellAtPos(Point(x,y)).Y;
ColNum := NxReportGridView61.GetCellAtPos(Point(x,y)).X;
Col6 := NxReportGridView61.GetColumnAt(x,y, gaHeader);
 

 

 IF (ColNum > -1) AND (RowNum > -1) THEN
        BEGIN
          IF RowExists(RowNum) AND NOT IsTextFit(ColNum, RowNum) THEN  <== how do I check for TextFit in a cell?
          // don't bother with hints if the cell has wordwrap
          BEGIN
            IF TNxTextColumn6(Col6).WrapKind <> TNxWrapKind(wkWordWrap) THEN
            BEGIN
              Cell[ColNum, RowNum].Hint := Cell[ColNum, RowNum].AsString
            END
            ELSE
            BEGIN
              Cell[ColNum, RowNum].Hint := ''
            END
          END
        END;
 
Thank you, 
Chuck Belanger
 


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 02 June 2023 - 12:32 AM

Hi,

 

There is no direct method for this (it's more internally used) like this (in TNxGridView6 class):

 

If you need a shorter version, maybe I can create it for you.

View := UpdateCellView(FHotCell.X, FHotCell.Y, CellRect); 
 
if not View.CanFitText then
begin
  Location := CellRect.TopLeft;
  ShowCellTextFitHint(Location, Columns[FHotCell.X].GetDisplayText(Cell, FHotCell.X, FHotCell.Y));
end;

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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 02 June 2023 - 12:38 AM

Hello again,

 

Here is the reference for this method: http://help.bergsoft.../UpdateCellView


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.

#4 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 02 June 2023 - 01:52 PM

Thank you, Boki, for the tip and reference.

 

Here is what I did. I am not at a place where I can test the code, but when I do and if needs changes I will return to keep this post's documentation correct.

 

again, this is in the OnMouseMove event

 

 WITH GridView2 DO
    BEGIN
      RowNum := NxReportGridView61.GetCellAtPos(Point(x,y)).Y;
      ColNum := NxReportGridView61.GetCellAtPos(Point(x,y)).X;
      Col6 := NxReportGridView61.GetColumnAt(x,y, gaHeader);
      ACellRect := NxReportGridView61.GetCellRect(x,y);
 
 
      IF (ColNum > -1) AND (RowNum > -1)
      and CellExists(ColNum, RowNum)
      and (Col6 is TNxTextColumn6) THEN
      BEGIN
 
        // limit hints to columns and rows that actually exist and the text doesn't fit
        // the cell
 
           AView := NxReportGridView61.UpdateCellView(x, y, ACellRect);
 
           if not AView.CanFitText then
           begin
             IF TNxTextColumn6(Col6).WrapKind <> TNxWrapKind(wkWordWrap) THEN
            BEGIN
              Cell[ColNum, RowNum].Hint := Cell[ColNum, RowNum].AsString
            END
            ELSE
            BEGIN
              Cell[ColNum, RowNum].Hint := ''
            END;
 
          end;
    end;


#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 02 June 2023 - 04:47 PM

Hello,

 

This seems ok, You are using this method correctly.


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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users