Jump to content


Photo

Show or Hide Checkbox


  • Please log in to reply
12 replies to this topic

#1 DelphiToday

DelphiToday
  • Members
  • 157 posts
  • Gender:Male

Posted 24 October 2023 - 08:47 PM

I want to hide or show the checkbox at the first column (0)

But I want to keep de Column.

I use: TNextVirtualGrid6

 

Attached File  BOKI 2023-10-24_193905.jpg   17.07KB   1 downloads

 

I want this?

How can I do this?

 

Attached File  BOKI2 2023-10-24_194423.jpg   16.63KB   1 downloads

 

 

Regards,

Eduard.



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 25 October 2023 - 07:52 PM

Hello Eduard,

 

I think that this event may help you:

http://help.bergsoft...lumn6/OnSetCell

 

Inside it, you can set http://help.bergsoft.../DrawingOptions property depending on row index. In your case you can simply turn off the content flag.

 

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.

#3 DelphiToday

DelphiToday
  • Members
  • 157 posts
  • Gender:Male

Posted 26 October 2023 - 12:18 PM

Hello Bojan,

 

I have tried the following two procedures. See code example. Both give me some random visibility or not and not fully drawn check-boxes. See picture attachment.

I must be thinking is this the right event to use?

Any idea?

 

Attached File  BOKI3 2023-10-26_105105.jpg   16.28KB   0 downloads

procedure TfrmFinalTranslate.NxCheckBoxColumn61SetCell(Sender: TObject; ACol, ARow: Integer; Cell: INxBaseCell);
var
  CheckVisible: Boolean;
  UseRec: TLanguageListType;
begin
  if InRange(ARow, 0, Pred(LanguageList.Count)) then
  begin
    UseRec := LanguageList[ARow];
    CheckVisible := (UseRec.Language = UseRec.Default) and (Length(UseRec.Ident0) > 0);
    (Sender as TNxCheckBoxColumn6).DrawingOptions := [doBackground, doContent];
    if (not CheckVisible) then
      (Sender as TNxCheckBoxColumn6).DrawingOptions := [doBackground];
  end;
end;

procedure TfrmFinalTranslate.NxReportGridView61GetCellGrid(Sender: TObject; ACol, ARow: Integer; var Edges: TNxBorderEdges; State: TNxCellPaintingState);
var
  CheckVisible: Boolean;
  UseRec: TLanguageListType;
begin
  if (ACol = 0) then
  begin
    if InRange(ARow, 0, Pred(LanguageList.Count)) then
    begin
      UseRec := LanguageList[ARow];
      CheckVisible := (UseRec.Language = UseRec.Default) and (Length(UseRec.Ident0) > 0);
      NextGrid.Columns[ACol].DrawingOptions := [doBackground, doContent];
      if (not CheckVisible) then
        NextGrid.Columns[ACol].DrawingOptions := [doBackground];
    end;
  end;
end;

Regards,

Eduard.
 

 



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 26 October 2023 - 08:19 PM

Hi Eduard,

 

I think that you don’t need the second one in your code (NxReportGridView61GetCellGrid). This probably makes some issues.


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 DelphiToday

DelphiToday
  • Members
  • 157 posts
  • Gender:Male

Posted 26 October 2023 - 09:10 PM

Hi Boki,

 

I was testing the two separately but doesn't work.

 

Now i try this one,

procedure TfrmFinalTranslate.NxCheckBoxColumn61SetCell(Sender: TObject; ACol, ARow: Integer; Cell: INxBaseCell);
var
  Index: Integer;
  UseRec: TLanguageListType;
  CheckVisible: Boolean;
begin
  Index := NextGrid.SelectedRow;
  if InRange(Index, 0, Pred(LanguageList.Count)) then
  begin
    UseRec := LanguageList[Index];
    CheckVisible := (UseRec.Language = UseRec.Default) and (Length(UseRec.Ident0) > 0);
    (Sender as TNxCheckBoxColumn6).DrawingOptions := [doBackground];
    if (CheckVisible) then
     (Sender as TNxCheckBoxColumn6).DrawingOptions := [doBackground, doContent];

    Caption := ARow.ToString + ' / ' + Index.ToString + ' - ' + UseRec.Output;
  end;
end;

The value ARow is not always correct so i use SelectedRow and that gives me de correct ROW.

 

But unfortunately the screen is the same. Checkboxes on the wrong place at random!

 

What now?

 

Regards,

Eduard. 

 

 



#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 26 October 2023 - 11:26 PM

Hello Eduart,

 

Cn you send me demo, or some even smaller project?

 

This will help. I think that SellectedRow property can cause problems in this case.


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 DelphiToday

DelphiToday
  • Members
  • 157 posts
  • Gender:Male

Posted 27 October 2023 - 05:34 AM

Hi Bojan,

 

You're right about SelectedRow because that wasn't good. But ARow also has an anomaly I think. 

 

Demo attached. Just move the cursor and the scroll bar. You can see that things are not going well.

 

Hope you can fix this.

 

Attached File   NextVirtualGridTest2023.zip   1.16MB   2 downloads



#8 DelphiToday

DelphiToday
  • Members
  • 157 posts
  • Gender:Male

Posted 28 October 2023 - 04:42 AM

Hi Bojan,

 

Have you take a look at my demo?



#9 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 28 October 2023 - 01:10 PM

Hi Eduard,

 

I’m working on it now. Will back to you as soon I found 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.

#10 DelphiToday

DelphiToday
  • Members
  • 157 posts
  • Gender:Male

Posted 28 October 2023 - 01:50 PM

That's fine Bojan.

 

I have made some alternative changes that's works for he moment.

Strange but true. I select all drawingoptions field TRUE in field Checkbox.

procedure TfrmFinalTranslate.NxCheckBoxColumn61DrawContent(Sender: TObject; ACol, ARow: Integer; CellRect: TRect; State: TNxCellPaintingState);
var
  UseRec: TLanguageListType;
  CheckVisible: Boolean;
begin
  if InRange(ARow, 0, Pred(LanguageList.Count)) then
  begin
    UseRec := LanguageList[ARow];
    CheckVisible := (UseRec.Language = UseRec.Default) and (Length(UseRec.Ident0) > 0);

    if (not CheckVisible) then
    begin
      with NextGrid.Canvas do
      begin
        Pen.Color := NextGrid.Color;
        Brush.Color := NextGrid.Color;
        if (ARow = NextGrid.SelectedRow) then
        begin
          if (NextGrid.Focused) then
            Brush.Color := NextGrid.SelectionColor
          else
            Brush.Color := NextGrid.InactiveSelectionColor;
        end;
        FillRect(CellRect);
      end;
    end;
  end;
end;

If you enabled False Checkbox, you can not move de selectionbar. Maybe also you can check?

I don't need this but maybe fine to check it out.

 

procedure TfrmFinalTranslate.NxCheckBoxColumn61SetCell(Sender: TObject; ACol, ARow: Integer; Cell: INxBaseCell);
var
  UseRec: TLanguageListType;
  CheckVisible: Boolean;
begin
   if InRange(ARow, 0, Pred(LanguageList.Count)) then
  begin
    UseRec := LanguageList[ARow];
    CheckVisible := (UseRec.Language = UseRec.Default) and (Length(UseRec.Ident0) > 0);
    NextGrid.Cell[0, ARow].Enabled := CheckVisible;
    // (Sender as TNxCheckBoxColumn6).Enabled := CheckVisible;
  end;
end;

 

 

 



#11 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 30 October 2023 - 03:40 PM

Hello Eduard,

 

In you second sample, maybe you can check State (TNxCellPaintingState) parameter and then adjust Canvas.Brush.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.

#12 DelphiToday

DelphiToday
  • Members
  • 157 posts
  • Gender:Male

Posted 30 October 2023 - 06:10 PM

You mean this part?

 Pen.Color := NextGrid.Color;
        Brush.Color := NextGrid.Color;
        if (ARow = NextGrid.SelectedRow) then
        begin
          if (NextGrid.Focused) then
            Brush.Color := NextGrid.SelectionColor
          else
            Brush.Color := NextGrid.InactiveSelectionColor;
        end;

What State type must I use. I remember I did not get it right some time ago...
 



#13 DelphiToday

DelphiToday
  • Members
  • 157 posts
  • Gender:Male

Posted 31 October 2023 - 07:38 AM

Changed it ! :)






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users