473,586 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug in DataGridView - invisible column turns visible...???

In my current project I've got some DataGridViews containing multiple hidden
columns.

For some reason 8 of the 10 grids I've got on my form has suddenly started
showing 1 of the hidden columns (not all of them). If I look at the grids in
the designer, the columns ARE invisible, but still they're shown at runtime.

I cannot figure out why. I've searched the entire project to see if I could
find any code setting the columns visible, but there isn't any.

Has anybody got a suggestion?

Cheers,
Johnny J.
Jul 20 '07 #1
4 2891
Can you post a simple but functional code sample to illustrate your issue?
Peter
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"Johnny Jörgensen" wrote:
In my current project I've got some DataGridViews containing multiple hidden
columns.

For some reason 8 of the 10 grids I've got on my form has suddenly started
showing 1 of the hidden columns (not all of them). If I look at the grids in
the designer, the columns ARE invisible, but still they're shown at runtime.

I cannot figure out why. I've searched the entire project to see if I could
find any code setting the columns visible, but there isn't any.

Has anybody got a suggestion?

Cheers,
Johnny J.
Jul 20 '07 #2
Not really, I tried posting screenshots though, but OE wouldn't let me do
that. Said the post was too large... :-(

I've got a Tab control with five tabs. On each tab I have 2 DataGridView
controls that are EXACTLY the same (the only difference is the displayed
data). All data comes from the same table but are filtered out into the 10
DataGridViews.

On the first tab everything is ok with the two DataGridViews, but on the 4
other tabs, the first column containing the ID is visible in both grids, and
if I check the designer properties, visible IS set to False for the columns.

I've tried searching the entire code and the visible property isn't changed
ANYWHERE (which I should also know seeing that I'm the only one developing
this application).

Strangely enough, sometimes it helps closing down Visual Studio and opening
it again. so it seems to be a VS problem more than a code problem.

As I said: I don't understand it...

Cheers,
Johhny J.

"Peter Bromberg [C# MVP]" <pb*******@yaho o.yohohhoandabo ttleofrum.comwr ote
in message news:D8******** *************** ***********@mic rosoft.com...
Can you post a simple but functional code sample to illustrate your issue?
Peter
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com



Jul 23 '07 #3
I get the same behavior in VB.NET '05 when I am closing a modal dialog form. I read on MSDN that the form's close() method should not be used when forms are opened using .ShowDialog(). You should use dispose() instead. This solved the issue for me.

Basically, the first time I enter the form, the columns were hidden as they should be. After closing the form with close(), subsequent visits to the form would show all columns as visible. When I closed the form with dispose(), subsequent visits rendered the columns as they were set in the designer.
Aug 21 '08 #4
On Thu, 21 Aug 2008 10:24:22 -0700, Ian <Freemanwrote :
I get the same behavior in VB.NET '05 when I am closing a modal dialog
form. I read on MSDN that the form's close() method should not be used
when forms are opened using .ShowDialog(). You should use dispose()
instead. This solved the issue for me.

Basically, the first time I enter the form, the columns were hidden as
they should be. After closing the form with close(), subsequent visits
to the form would show all columns as visible. When I closed the form
with dispose(), subsequent visits rendered the columns as they were set
in the designer.
Did you have a question?

In VB.NET, if you're seeing the behavior you describe, then you probably
have made the additional mistake of not explicitly instantiating your
dialog object before showing it. When you do that, VB.NET will use its
"default instance", which is the same for each invocation of the dialog.

This isn't possible in C# and so it would be obvious to the person using
the dialog whether they are reusing the same instance or creating a new
one each time they show the dialog.

As far as Close() vs Dispose() goes...yes, it's true that you need to call
Dispose() explicitly on forms shown with ShowDialog(). These forms are
not disposed implicitly when they are closed, because a common pattern of
usage is to close them and _then_ retrieve user input or other information
from the controls found in the form. Were the form to be disposed on
close, as non-modal forms are, these controls would also have already been
disposed by the time the code tries to get the data from them.

But this also means that simply calling Dispose() is usually not an
appropriate way to close a modal form. In particular, most modal forms do
in fact have data that the caller is going to want to get at after the
form's been closed. So the right thing to do is call Close() (which for a
modal form simply hides it), and then rely on the caller to call Dispose()
after they've gotten the information from the form that they want.

Pete
Aug 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3982
by: Roy | last post by:
What is the best way to approach this problem? I have a datagrid with an imagebutton. When one clicks the imagebutton it triggers an onClick sub which makes column 9 (a user control) visible or invisible. Only problem is when one clicks the imagebutton on a specific row, I want *only* that row's column 9 to appear or disappear. ********My...
4
1283
by: Danny Nielsen | last post by:
Hi I am new to vb.net 2005 (in fact vb in general as well). I have tried creating a datagridview with 4 columns, with one as a DataGridViewCheckBoxColumn. My problem are that data has been put in the way they should from my db but updates arent visible on this particular column. The data are either 1 or 2 and I have put in these values on...
4
20287
by: osmarjunior | last post by:
When I try to make the current row invisible, I got an error. I put a checbox that turns some rows visible/invisible. Then if the selected row is turning to invisible, it raises an exception. My code: foreach (DataGridViewRow row in myGrid.Rows) if ((bool)row.Cells.Value.Equals(false)) row.Visible = checkbox.Checked;
3
437
by: Art | last post by:
Hi, I'm having some trouble with my DataGridView. I have it bound to a DataTable. One column of the grid is a boolean that says whether a row should be visible. There is also a checkbox outside of the grid that toggles whether or not the marked rows should be displayed or not. The problem happens as follows: The toggle is set so that...
3
2882
by: rockdale | last post by:
Hi, All: I have a datagrid with TemplateColumn as following: <asp:TemplateColumn Visible="False" > <ItemStyle Width="0px"></ItemStyle> <ItemTemplate> <asp:Label id="lblMin_Value" Visible=False runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.min_value") %>'> </asp:Label>
3
1543
by: finleeds | last post by:
hi all I m using the visual studio designer to create 1 Dataset with 1 table with 3 columns : Id, Name, Birthday. Once this done, still with the designer, I m creating a datagridview and choose my dataset as DataSource. magic : the columns appear in the datagridview.
3
5071
by: =?Utf-8?B?U3RldmVU?= | last post by:
Is it possible with VS 2005 to hide a row within a datagridview based upon the "true/false" status of another boolean property within the datagridview? -- ----------- Thanks, Steve
2
1818
by: Johnny Jörgensen | last post by:
In my current project I've got some DataGridViews containing multiple hidden columns. For some reason 8 of the 10 grids I've got on my form has suddenly started showing 1 of the hidden columns (not all of them). If I look at the grids in the designer, the columns ARE invisible, but still they're shown at runtime. I cannot figure out why....
1
3369
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons: 1) export to excel button exports the visible columns from the datagridview to excel (this works fine)
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8216
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.