By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,372 Members | 1,197 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,372 IT Pros & Developers. It's quick & easy.

DataGrid column Visible issue

P: n/a
(one of our developers posted this and it got no answer so I'm giving it
another try)

I'm converting a DataGrid utility component that previously used the columns
array to function as it has in the past without using the columns array.
The reason for this is because it must process columns created at run time
which does not create entries in the columns array.....

My problem is that if datagrid columns created at design time are defined as
non-visible the cells in those columns still still test as visible !!

For instance if I....
Dim FirstRow As DataGridItem = mygrid.Items(0)

and then test..

If FirstRow.Cells(0).Visible = True Then

cells for the non visible column test as visible.

How can I get a true test without using the columns array??

Regards,
Gary Blakely
Oct 6 '06 #1
Share this Question
Share on Google+
7 Replies

P: n/a
You need to catch it when it's good and ready, so you might want to handle
one of the item databound or created items (though I think item created
event may be too early).

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"GaryDean" <Ga******@newsgroups.nospamwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
(one of our developers posted this and it got no answer so I'm giving it
another try)

I'm converting a DataGrid utility component that previously used the
columns
array to function as it has in the past without using the columns array.
The reason for this is because it must process columns created at run time
which does not create entries in the columns array.....

My problem is that if datagrid columns created at design time are defined
as
non-visible the cells in those columns still still test as visible !!

For instance if I....
Dim FirstRow As DataGridItem = mygrid.Items(0)

and then test..

If FirstRow.Cells(0).Visible = True Then

cells for the non visible column test as visible.

How can I get a true test without using the columns array??

Regards,
Gary Blakely


Oct 6 '06 #2

P: n/a
Alvin,
Sorry but I don't understand your answer. this is a datagrid object being
passed to a component. It's got nothing to do with "when" it's being looked
at. For instance column 4 is non-visible but cells in column 4 test as
visible.

--
Regards,
Gary Blakely

"Alvin Bruney [MVP]" <www.lulu.com/owcwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
You need to catch it when it's good and ready, so you might want to
handle one of the item databound or created items (though I think item
created event may be too early).

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"GaryDean" <Ga******@newsgroups.nospamwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
>(one of our developers posted this and it got no answer so I'm giving it
another try)

I'm converting a DataGrid utility component that previously used the
columns
array to function as it has in the past without using the columns array.
The reason for this is because it must process columns created at run
time
which does not create entries in the columns array.....

My problem is that if datagrid columns created at design time are defined
as
non-visible the cells in those columns still still test as visible !!

For instance if I....
Dim FirstRow As DataGridItem = mygrid.Items(0)

and then test..

If FirstRow.Cells(0).Visible = True Then

cells for the non visible column test as visible.

How can I get a true test without using the columns array??

Regards,
Gary Blakely



Oct 7 '06 #3

P: n/a
ah but it has. my point was that the test is valid in the correct event
handler.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"GaryDean" <Ga******@newsgroups.nospamwrote in message
news:Ou*************@TK2MSFTNGP05.phx.gbl...
Alvin,
Sorry but I don't understand your answer. this is a datagrid object being
passed to a component. It's got nothing to do with "when" it's being
looked at. For instance column 4 is non-visible but cells in column 4
test as visible.

--
Regards,
Gary Blakely

"Alvin Bruney [MVP]" <www.lulu.com/owcwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
>You need to catch it when it's good and ready, so you might want to
handle one of the item databound or created items (though I think item
created event may be too early).

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"GaryDean" <Ga******@newsgroups.nospamwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
>>(one of our developers posted this and it got no answer so I'm giving it
another try)

I'm converting a DataGrid utility component that previously used the
columns
array to function as it has in the past without using the columns array.
The reason for this is because it must process columns created at run
time
which does not create entries in the columns array.....

My problem is that if datagrid columns created at design time are
defined as
non-visible the cells in those columns still still test as visible !!

For instance if I....
Dim FirstRow As DataGridItem = mygrid.Items(0)

and then test..

If FirstRow.Cells(0).Visible = True Then

cells for the non visible column test as visible.

How can I get a true test without using the columns array??

Regards,
Gary Blakely




Oct 7 '06 #4

P: n/a
the datagrid was created and displayed on the page. All of the events fired
on the server a long long time ago. Now someone pushes a button on the form
and the server responds by passing the grid to a component method. At this
point the grid is a static object - it can be examined and it is indeed
complete with all the data and attributes set.

Except that cells for non-visible columns are set to visible.

--
Regards,
Gary Blakely

"Alvin Bruney [MVP]" <www.lulu.com/owcwrote in message
news:e2**************@TK2MSFTNGP02.phx.gbl...
ah but it has. my point was that the test is valid in the correct event
handler.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"GaryDean" <Ga******@newsgroups.nospamwrote in message
news:Ou*************@TK2MSFTNGP05.phx.gbl...
>Alvin,
Sorry but I don't understand your answer. this is a datagrid object
being passed to a component. It's got nothing to do with "when" it's
being looked at. For instance column 4 is non-visible but cells in
column 4 test as visible.

--
Regards,
Gary Blakely

"Alvin Bruney [MVP]" <www.lulu.com/owcwrote in message
news:uH**************@TK2MSFTNGP04.phx.gbl...
>>You need to catch it when it's good and ready, so you might want to
handle one of the item databound or created items (though I think item
created event may be too early).

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"GaryDean" <Ga******@newsgroups.nospamwrote in message
news:u3**************@TK2MSFTNGP04.phx.gbl...
(one of our developers posted this and it got no answer so I'm giving
it another try)

I'm converting a DataGrid utility component that previously used the
columns
array to function as it has in the past without using the columns
array.
The reason for this is because it must process columns created at run
time
which does not create entries in the columns array.....

My problem is that if datagrid columns created at design time are
defined as
non-visible the cells in those columns still still test as visible !!

For instance if I....
Dim FirstRow As DataGridItem = mygrid.Items(0)

and then test..

If FirstRow.Cells(0).Visible = True Then

cells for the non visible column test as visible.

How can I get a true test without using the columns array??

Regards,
Gary Blakely




Oct 7 '06 #5

P: n/a
Hi Gary,

As for the DataGrid's Columns collection, when one of the DataGridColumn's
Visible it set to false (at design-time or runtime), it will not directly
change the underlying Cell(in the certain DataGridRow)'s Visible property
because at that time the certain Row or Cell may still hasn't been
constructed or initialized completely. I've checked the disassembly code
of the DataGrid control, the actual code logic for applying the
DataGridColumn.Visible is as below:

** we set a certain column's Visible to false (at design-time or runtime)

** the DataGrid still create each DataGridRow and cells in each row as
normal (without set the visible property on each cell)

** in the DataGrid.Render method, it will call a "PrepareControlHierarchy"
method and in this method the DataGrid will loop through all the columns
and apply the certain DataGridColumn.Visible setting to the corresponding
Cell.

Therefore, for your scenario, if you want to detect a certain Cell's
visibility, you can not use the "Visible" property since it is not
synchorized with the Column's Visible before rendering. I suggset you check
the Column's Visible property from the DataGrid's Columns collection and
determine the corresponding Cell(by index)'s visible setting. How do you
think of this?

Please feel free to let me know if you have any other concerns or questions
here.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 9 '06 #6

P: n/a
I can't check the Column's Visible property because columns created at run
time have no columns collection.

(my situation may make sense now that you have read my "Getting DataGrid
Header information' thread)

As it turns out I'm saved because if columns in a grid are created at run
time then those columns can't be set to non-visible because there is no
columns collection. the developer that created the datagrid would have to
set the cells themselves to non visible in the ItemDataBound event. so I
don't think I have a problem here after all.

--
Regards,
Gary Blakely

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:Cg**************@TK2MSFTNGXA01.phx.gbl...
Hi Gary,

As for the DataGrid's Columns collection, when one of the DataGridColumn's
Visible it set to false (at design-time or runtime), it will not directly
change the underlying Cell(in the certain DataGridRow)'s Visible property
because at that time the certain Row or Cell may still hasn't been
constructed or initialized completely. I've checked the disassembly code
of the DataGrid control, the actual code logic for applying the
DataGridColumn.Visible is as below:

** we set a certain column's Visible to false (at design-time or runtime)

** the DataGrid still create each DataGridRow and cells in each row as
normal (without set the visible property on each cell)

** in the DataGrid.Render method, it will call a "PrepareControlHierarchy"
method and in this method the DataGrid will loop through all the columns
and apply the certain DataGridColumn.Visible setting to the corresponding
Cell.

Therefore, for your scenario, if you want to detect a certain Cell's
visibility, you can not use the "Visible" property since it is not
synchorized with the Column's Visible before rendering. I suggset you
check
the Column's Visible property from the DataGrid's Columns collection and
determine the corresponding Cell(by index)'s visible setting. How do you
think of this?

Please feel free to let me know if you have any other concerns or
questions
here.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Oct 9 '06 #7

P: n/a
Thanks for your reply Gary,

Glad that you no longer suffer this problem. Anyway, if you meet any other
issue on this later, please feel free to post here.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 10 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.