Datagridview columns hiding

P

Peted

Hi
using vs 2008 c#

i wonder if anyone can suggest on how i can achieve the following


I have a datagridview on a form, and i have a user preferences
confiuration dialog that allows a user to make any column on this
datagrid visible or invisible.

This of course uses the datagridview column properties Visbile.

This is fine, except that on the grid i have some columns that i never
want visible, never accessable to the user (but visible to me in the
source code. If i just use visible = false, then they appear in the
"hidden columns" list, and this allows the user to set them to
visible.

So i need a way to make a column invisble and "tag" it in some way so
i can test it so i can prevent it appearing in a list of "hidden
columns"

As far as i can see there is no TAG property for columns.

If anyone has any suggestions thanks in advance.

Peted
 
L

Larry Smith

As far as i can see there is no TAG property for columns.

yourDataGridView.Columns[whatever].Tag
 
S

Sunita

Hi
using vs 2008 c#

i wonder if anyone can suggest on how i can achieve the following

I have a datagridview on a form, and i have a user preferences
confiuration dialog that allows a user to make any column on this
datagrid visible or invisible.

This of course uses the datagridview column properties Visbile.

This is fine, except that on the grid i have some columns that i never
want visible, never accessable to the user (but visible to me in the
source code. If i just use visible = false, then they appear in the
"hidden columns" list, and this allows the user to set them to
visible.

So i need  a way to make a column invisble and "tag" it in some way so
i can test it so  i can prevent it appearing in a list of "hidden
columns"

As far as i can see there is no TAG property for columns.

If anyone has any suggestions thanks in advance.

Peted

Hi,

You can take the help of datakey, sothat you can access the hidden
column.


<asp:GridView ID="dgv" runat="server" DataKeyNames ="Name">
<asp:BoundField HeaderText ="UserName" DataField ="Name" Visible
="false" />
</asp:GridView>

In your code behind, you can access this hidden column as given below.
string strName= Convert.ToString(dgv.DataKeys[dgv.SelectedIndex].Values
["Name"]);

Sunita
 

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