Jump to content


Photo

GetDisplayText gives Exception on invisible rows


  • Please log in to reply
3 replies to this topic

#1 Lothar

Lothar
  • Members
  • 16 posts

Posted 11 January 2019 - 04:56 PM

Hello Boki,

 

In a loop over all rows and columns I need DisplayText to find out the width of the text.

 

When the loop gets to the invivible rows it gives an exception of class EVariantTypeCastError with the message:

"Variant of type (OleStr) coulnd't be converted into type (Integer)".

 

the line of code is:

:= aNextGrid.Columns[Col].GetDisplayText(aNextGrid.Cell[Col, Row], Col, Row);

 

I hope you will find a solution.

Thanks in advance

Lothar



#2 Lothar

Lothar
  • Members
  • 16 posts

Posted 11 January 2019 - 06:07 PM

Hello Boki,

 

it didn't work in NextGrid5.

 

My call was: aNextGrid.GetDrawText(Col, Row))

GetDrawText only gave back: Cell.AsString;

 

Now I have also TNxDBLookupColumn6 and for this I need the GetDisplayText.

 

Best regards

Lothar



#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 11 January 2019 - 09:23 PM

Hello Lothar,

Can you please send me one very simple example project.
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 Lothar

Lothar
  • Members
  • 16 posts

Posted 14 January 2019 - 06:08 PM

Hello Boki,

 

I solved it.

 

The little example project worked. So I looked at the differencs and I found, that I had set BufferRecords = false.

 

With BufferRecords = True it works.

 

 

And there is still a question left to this subject:

How do I find out about the size for TNxCheckBoxColumn6 what it needs to display?

See the code below. It loops over all rows anc columns to find out the display width in order to set the width of the column correctly

 

Thanks for being there

Lothar

 

 

  for Col := 0 to aNextGrid.Columns.Count - 1 do
  begin
    if aNextGrid.Columns[Col].Visible then
    begin
      for Row := 0 to aNextGrid.RowCount - 1 do
      begin
        if aNextGrid.Columns[Col] is TNxButtonColumn6 then
          lng := TNxButtonColumn6(aNextGrid.Columns[Col]).ButtonWidth
        else
        if aNextGrid.Columns[Col] is TNxCheckBoxColumn6 then
          lng := TNxCheckBoxColumn6(aNextGrid.Columns[Col]).   ?????????
        else
        if aNextGrid.Columns[Col] is TNxGraphicColumn6 then
        begin
          Graphic := TNxGraphicColumn6(aNextGrid.Columns[Col]).GetGraphic(aNextGrid.Cell[Col, Row], Col, Row);
          if Assigned(Graphic) then
            lng := Graphic.Width
          else
            lng := 0;
        end
        else
        if aNextGrid.Columns[Col] is TNxIconColumn6 then
        begin
          if TNxIconColumn6(aNextGrid.Columns[Col]).Index >=0 then
          begin
            Icon := TIcon.Create;
            try
              TNxIconColumn6(aNextGrid.Columns[Col]).Images.GetIcon(TNxIconColumn6(aNextGrid.Columns[Col]).Index, Icon);
              lng := Icon.Width;
            finally
              Icon.Free;
            end;
          end
          else
            lng := 0;
        end
        else
          lng := GetTextWidth(aNextGrid.Columns[Col].Font, aNextGrid.Columns[Col].GetDisplayText(aNextGrid.Cell[Col, Row], Col, Row));
 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users