Jump to content


Photo

ClearRows?


  • Please log in to reply
10 replies to this topic

#1 Speed

Speed
  • Members
  • 190 posts
  • Gender:Male

Posted 11 December 2020 - 07:58 AM

Does NextGrid v6 have a ClearRows method?

 

= Steve

 



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 11 December 2020 - 03:19 PM

Hi,

 

Sure it have. It is:

 

 NextGrid61.ClearRows;

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 Speed

Speed
  • Members
  • 190 posts
  • Gender:Male

Posted 12 December 2020 - 12:58 AM

Ok, that's weird.  It didn't show up with code insight.

 

Thanks.

 

= Steve



#4 myicq

myicq
  • Members
  • 16 posts

Posted 19 February 2021 - 12:48 PM

I have experimented a little with this, and believe I have found a mistake.

 

Apparently the

clearrows

command does not reset the display of row borders.

 

See this small example where I clear everything and add columns and rows. First I create 8 cols x 10 rows.

 

nxgrid1.jpg

Then I make one with less rows, less columns:

nxgrid2.jpg

 

I have two events on the "view" part: coloring odd/even rows, and making the border. The coloring is OK I guess. My border function is here:

procedure TForm1.ViewGetCellGrid(Sender: TObject; ACol, ARow: Integer;
  var Edges: TNxBorderEdges; State: TNxCellPaintingState);
var
  mystyleBlank : TNxBorderEdges;
  mystyleNormal : TNxBorderEdges;
begin
   mystyleBlank[beright].Color := clwhite;  // right
   mystyleBlank[beRight].Style := psClear;
   mystyleblank[beBottom] := mystyleblank[beRight];
   mystyleblank[beLeft] := mystyleblank[beRight];
   mystyleblank[beTop] := mystyleblank[beRight];

   mystyleNormal[beright].Color := clBlack;  // right
   mystyleNormal[beRight].Style := psSolid;
   mystyleNormal[beBottom] := mystyleNormal[beRight];
   mystyleNormal[beLeft] := mystyleNormal[beRight];
   mystyleNormal[beTop] := mystyleNormal[beRight];

    // Do not want to add borders to more than defined, in the view
    //
      if arow > nxGrid.RowCount-1 then
          Edges :=mystyleBlank
      else
          edges := mystyleNormal;
end;

Before re-doing the table I run these:

   with nxGrid do
    begin

       BeginUpdate();
       for myrows := RowCount-1 downto 0 do
               DeleteRow(myrows);
       EndUpdate();
       ClearRows;
       clear;
    // create code follows
    //...
    end;

I have tried just clear; and others alone, same result.

 

Is this confirmed ?

 

This is nextgrid 6.3.7, same is confirmed for 6.6.0.



#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 19 February 2021 - 01:49 PM

Hello,

 

Maybe you can try with calling Invalidate on the grid immediately after you call ClearRows. Like:

 

NextGrid61.ClearRows;
NextGrid61.Invalidate;

 

I hope that this helps.


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.

#6 myicq

myicq
  • Members
  • 16 posts

Posted 19 February 2021 - 06:21 PM

Maybe you can try with calling Invalidate on the grid immediately after you call ClearRows. Like:

NextGrid61.ClearRows;
NextGrid61.Invalidate;

 

Boki,

 

there is no difference doing that.

 

I will attach my sample project here. Try to add 8 cols and 10 rows, then reduce both cols and rows.

I would like to have the grid lines enabled, but custom-drawn only for defined rows. This works. But only as I constantly increase the row count.

 

 

Attached Files



#7 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 19 February 2021 - 08:35 PM

Hi,

 

Thanks, I will investigate it and try to find the solution.


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.

#8 myicq

myicq
  • Members
  • 16 posts

Posted 19 February 2021 - 10:14 PM

Related to this suggest a global option to automatically only draw for the defined table, instead of filling rows for the entire area of container. If possible ?



#9 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 20 February 2021 - 12:56 PM

Hello,

 

For 1st question, try changing this line in your code:

 

  mystyleBlank[beRight].Style := psSolid; // but then later set to desired color.

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

Boki (Berg)

    Boki (Berg)

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

Posted 20 February 2021 - 12:57 PM

Related to this suggest a global option to automatically only draw for the defined table, instead of filling rows for the entire area of container. If possible ?

Can you please give me more details, I didn't understood the question very well.


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.

#11 myicq

myicq
  • Members
  • 16 posts

Posted 02 March 2021 - 10:37 PM

Can you please give me more details, I didn't understood the question very well.

 

Boki, the first suggestion worked great. Thank you! I am puzzled why I would change [beRight] as the issue is with horizontal lines, not vertical. But anyway, if it works.

 

For the second part, look at the sample code in event for the view:

procedure TForm1.ViewGetCellColor(Sender: TObject; ACol, ARow: Integer;
  var CellColor: TColor; State: TNxCellPaintingState);
var
  oddCol, evenCol : TColor;
begin
       oddcol :=  RowColorODD.SelectedColor;
       evencol := RowColorEVEN.SelectedColor;

//   if (Arow< nxGrid.RowCount)  then        // <<<<<<<<<<<<<<<<<<<<<<<<<<<
    if Odd(aRow) then CellColor := oddcol
     else
     cellcolor := evencol;

end;

Essentially the entire container for the grid is always painted even if rowcount is less than needed to fill it.  This is a little confusing.

 

My suggestion was to make this implicit: making rows > the defined rows invisible by default.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users