Hide Column in Datagrid

M

Michael

Hello,

After 2 years i come back to DOT NET development, so it is a little bit hard
in the beginning.

Here is my problem :

I have a table with a field whixh tells me if a person is a boy or a girl,
it is a boolean (0 or 1).

In my window application, i want to show a list of person, and i do it
dynamically when the datagrid is created. I have not associated a Datasource
with any wizard, i do it manually in the code.

At first, i had a column with checkboxes to represent my Sex field value,
quite logic for the moment, but i wanted to show "Boy" or "Girl" instead.
So i add a new column to my dataset, with the expression : IIF(Sexe, 'Boy',
'Girl'), this is working fine.

But now i want to hide the original column (Sexe field) in my datagrid, but
i can't find a way to do it, as there is no "Datacolumns" or
"DataColumnCollection" property in System.windows.forms.Datagrid.

Here is a piece of code :

//Ajout de la colonne Garçon/Fille

System.Data.DataColumn cSexe = new System.Data.DataColumn();

cSexe.ColumnName = "Genre";

cSexe.Expression = "IIF(Sexe, \'Garçon\', \'Fille\')";

cSexe.ReadOnly = true;

monDS.Tables["Competiteur"].Columns.Add(cSexe);

this.dgCompetiteurs.DataSource = monDS.Tables["Competiteur"];



Thanks in advance for all your answers.



Michael
 
M

Michael

Thanks a lot for your help, it works fine.

Merci beaucoup pour ton aide :p

Eric Moreau (VB MVP) said:
see http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp#q708q

--

HTH

Éric Moreau
MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)


Michael said:
Hello,

After 2 years i come back to DOT NET development, so it is a little bit
hard in the beginning.

Here is my problem :

I have a table with a field whixh tells me if a person is a boy or a
girl, it is a boolean (0 or 1).

In my window application, i want to show a list of person, and i do it
dynamically when the datagrid is created. I have not associated a
Datasource with any wizard, i do it manually in the code.

At first, i had a column with checkboxes to represent my Sex field value,
quite logic for the moment, but i wanted to show "Boy" or "Girl" instead.
So i add a new column to my dataset, with the expression : IIF(Sexe,
'Boy', 'Girl'), this is working fine.

But now i want to hide the original column (Sexe field) in my datagrid,
but i can't find a way to do it, as there is no "Datacolumns" or
"DataColumnCollection" property in System.windows.forms.Datagrid.

Here is a piece of code :

//Ajout de la colonne Garçon/Fille

System.Data.DataColumn cSexe = new System.Data.DataColumn();

cSexe.ColumnName = "Genre";

cSexe.Expression = "IIF(Sexe, \'Garçon\', \'Fille\')";

cSexe.ReadOnly = true;

monDS.Tables["Competiteur"].Columns.Add(cSexe);

this.dgCompetiteurs.DataSource = monDS.Tables["Competiteur"];



Thanks in advance for all your answers.



Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top