Hiding a grid column

  • Thread starter Thread starter STom
  • Start date Start date
S

STom

I am adding grid columns to me grid like so:

column = New DataGridTextBoxColumn
column.MappingName = "ValuePercent"
column.HeaderText = "Percent"
column.Width = 50
tableStyle.GridColumnStyles.Add(column)

Is there a way I can add a column that is not visible?

What I would like to do create two columns in my grid that already have data values in them. Not quite sure how to do that.

Thanks.

Stom
 
One easy way of doing this is to create the column like usual but set the
Width to 0 so it is not shown.

--
Tim Wilson
..Net Compact Framework MVP

I am adding grid columns to me grid like so:

column = New DataGridTextBoxColumn
column.MappingName = "ValuePercent"
column.HeaderText = "Percent"
column.Width = 50
tableStyle.GridColumnStyles.Add(column)
Is there a way I can add a column that is not visible?
What I would like to do create two columns in my grid that already have data
values in them. Not quite sure how to do that.
Thanks.
Stom
 
Tim said:
One easy way of doing this is to create the column like usual but set the
Width to 0 so it is not shown.

I understand it's better to set the width to -1 to avoid any spurious
lines....

/steveA
 
I have always used 0 and have never had a problem. Everything paints as it
should and the illusion is made that the column doesn't exist. So from my
perspective 0 and -1 will do the exact same thing. When have you encountered
"spurious lines" with a 0 width?
 
Hi Stom,

Check out the following FAQ "How do I hide a column" in George Shepherd's Windows Forms FAQ

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q708q

Regards,
Arun

I am adding grid columns to me grid like so:

column = New DataGridTextBoxColumn
column.MappingName = "ValuePercent"
column.HeaderText = "Percent"
column.Width = 50
tableStyle.GridColumnStyles.Add(column)

Is there a way I can add a column that is not visible?

What I would like to do create two columns in my grid that already have data values in them. Not quite sure how to do that.

Thanks.

Stom
 
If I hide a column by setting its width to zero, when I tab through the
columns, won't it seem like the tab is not working when it hits the '0'
width column? Of course you could hit the tab again to keep move to the next
column, but I would think that users might think this is a bug.

Thanks.

STom
Tim Wilson said:
I have always used 0 and have never had a problem. Everything paints as it
should and the illusion is made that the column doesn't exist. So from my
perspective 0 and -1 will do the exact same thing. When have you encountered
"spurious lines" with a 0 width?
 
That is true. I forgot about that because in some situations I have the
DataGrid set up to ignore tabs and this doesn't become an issue for me. If
you are using a TableStyle then you might want to create a method that you
can call that just rebuilds the TableStyle as needed.

--
Tim Wilson
..Net Compact Framework MVP

STom said:
If I hide a column by setting its width to zero, when I tab through the
columns, won't it seem like the tab is not working when it hits the '0'
width column? Of course you could hit the tab again to keep move to the next
column, but I would think that users might think this is a bug.

Thanks.

STom
 
Back
Top