Topic: how to show or hide columns from checkbox

hi

please
how to show or hide columns in Table Grid from checkbox

Re: how to show or hide columns from checkbox

Hello mouasomar
I do like this snippet to hide/unhide column(s) of a tablegrid :

procedure Afficher_Colonnes_CheckBox17_OnClick (Sender: TObject);
begin
       Form1.TableGrid1.Columns[16].Visible := Afficher_Colonnes.CheckBox17.Checked;    // Colonne Date de retrait
end;

procedure Afficher_Colonnes_CheckBox16_OnClick (Sender: TObject);
begin
      Form1.TableGrid1.Columns[15].Visible := Afficher_Colonnes.CheckBox16.Checked;    // Colonne Date de parution
end;

procedure Afficher_Colonnes_CheckBox15_OnClick (Sender: TObject);
begin
     Form1.TableGrid1.Columns[14].Visible := Afficher_Colonnes.CheckBox15.Checked;    // Colonne Type de poste
end;

procedure Afficher_Colonnes_CheckBox14_OnClick (Sender: TObject);
begin
     Form1.TableGrid1.Columns[13].Visible := Afficher_Colonnes.CheckBox14.Checked;    // Colonne Qualité
end;

procedure Afficher_Colonnes_CheckBox13_OnClick (Sender: TObject);
begin
    Form1.TableGrid1.Columns[12].Visible := Afficher_Colonnes.CheckBox13.Checked;    // Colonne Type d'impression
end;

procedure Afficher_Colonnes_CheckBox12_OnClick (Sender: TObject);
begin
     Form1.TableGrid1.Columns[11].Visible := Afficher_Colonnes.CheckBox12.Checked;    // Colonne Dentelure
end;

procedure Afficher_Colonnes_CheckBox11_OnClick (Sender: TObject);
begin
    Form1.TableGrid1.Columns[10].Visible := Afficher_Colonnes.CheckBox11.Checked;    // Colonne Statut
end;

procedure Afficher_Colonnes_CheckBox10_OnClick (Sender: TObject);
begin
    Form1.TableGrid1.Columns[9].Visible := Afficher_Colonnes.CheckBox10.Checked;    // Colonne Graveurs
end;

procedure Afficher_Colonnes_CheckBox9_OnClick (Sender: TObject);
begin
     Form1.TableGrid1.Columns[8].Visible := Afficher_Colonnes.CheckBox9.Checked;    // Colonne Dessinateurs
end;

procedure Afficher_Colonnes_CheckBox8_OnClick (Sender: TObject);
begin
      Form1.TableGrid1.Columns[7].Visible := Afficher_Colonnes.CheckBox8.Checked;    // Colonne Couleurs
end;

procedure Afficher_Colonnes_CheckBox7_OnClick (Sender: TObject);
begin
      Form1.TableGrid1.Columns[6].Visible := Afficher_Colonnes.CheckBox7.Checked;    // Colonne Valeur faciale
end;

procedure Afficher_Colonnes_CheckBox6_OnClick (Sender: TObject);
begin
     Form1.TableGrid1.Columns[5].Visible := Afficher_Colonnes.CheckBox6.Checked;    // Colonne Année
end;

procedure Afficher_Colonnes_CheckBox5_OnClick (Sender: TObject);
begin
     Form1.TableGrid1.Columns[4].Visible := Afficher_Colonnes.CheckBox5.Checked;    // Colonne Thème
end;

procedure Afficher_Colonnes_CheckBox4_OnClick (Sender: TObject);
begin
     Form1.TableGrid1.Columns[3].Visible := Afficher_Colonnes.CheckBox4.Checked;    // Colonne Série
end;

procedure Afficher_Colonnes_CheckBox3_OnClick (Sender: TObject);
begin
     Form1.TableGrid1.Columns[2].Visible := Afficher_Colonnes.CheckBox3.Checked;    // Colonne Désignation
end;

Probably not the best way but it makes the job
JB

3 (edited by mouasomar 2024-08-05 21:12:38)

Re: how to show or hide columns from checkbox

Merci /jean.brezhonek

. Pouvez-vous me donner un simple projet  qui démontre cette fonctionnalité

Thanks  /jean.brezhonek.
Can you give me a simple project that demonstrates this feature?

Re: how to show or hide columns from checkbox

Here is an example found on the forum.

Post's attachments

Attachment icon Filter by checkbox.zip 349.32 kb, 106 downloads since 2024-08-06 

Destiny

5 (edited by mouasomar 2024-08-06 11:47:46)

Re: how to show or hide columns from checkbox

THANKS
please I want to hide or show columns. not rows

Re: how to show or hide columns from checkbox

Hi Mouasomar, Jean, Destiny,
Perhaps try it something like this (see attached).
Click on the 'Columns' button, select which columns to show / hide and then click again on the 'Columns' button.
Derek.

Post's attachments

Attachment icon hide columns.zip 447.21 kb, 122 downloads since 2024-08-07 

Re: how to show or hide columns from checkbox

Hi Mouasomar, Hi Destiny 'Hello from Rennes'), Hello Derek (How are you?)
Here is my MVD application to manage my stamps.
At the bottom of the grid, you will see the "Show/Hide columns" checkbox.
When you check the box, a form is displayed with all the columns present on the grid.
From this form, you check/uncheck the column(s) you want to hide or display.
By default, the checked box displays the column.
Derek's method is just as effective.
JB

Post's attachments

Attachment icon MES_TIMBRES_23112022.ZIP 1.65 mb, 120 downloads since 2024-08-07