473,395 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DataGrid column Visible issue

(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
7 2004
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
0
by: Robert Brinson | last post by:
Hello all! I'm running .NET Framework 1.1 using VS.NET 2003. I've got a mystery with a DataGrid. Below is the definition of the DataGrid from my aspx page: </asp:datagrid><asp:datagrid...
12
by: Daniel Walzenbach | last post by:
Hi, I want to display a Label in a DataGrid according to some condition. I therefore check whether the condition is true in the ItemDateBound EventHandler of the DataGrid. Unfortunately the...
9
by: tshad | last post by:
I have a datagrid that I want to add a new column to. This column will only be visible under certain conditions. So I want to set the column visible=false. Then when the right condition happens...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
8
by: Moondog | last post by:
I am referencing a datagrid item like this: strItemNo = grdItems.Item(grdItems.CurrentRowIndex(), 0) The Item Number is in the first column; column 0. It works fine except this is not a...
9
by: Steve | last post by:
How I can remove an AutoGenerated column? I wnat to inlcude the primary key in the resultset for creating some custom LinkButtons, but I don't want it (the PK) displayed in the DataGrid. I tried...
4
by: Hexman | last post by:
I was going along fine in my test to see how to manipulate the DataGrid (dgTrans) and its columns. I have a single form with one DataGrid (dgTrans) on it. The code I have in my form load event...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.