Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2006

Tip: Looking for answers? Try searching our database.

Can't Make Primary Key Column Invisible in DataGrid?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joseph Geretz - 25 Dec 2006 03:37 GMT
Visual Studio 2005 / FX 2.0

I've got a datagrid which is bound to a BindingSource, pretty standard
stuff. Basically the grid is populated with every column from the underlying
table. I've got some columns marked as invisible, however the primary key
column keeps showing up. The best I can do is set this to width 5, but this
isn't what I want. Why can't I get this column to be invisible?

Thanks!

- Joe Geretz -
RobinS - 25 Dec 2006 06:58 GMT
I think I read this same problem in a posting a while back.
Try putting all the columns that are going to be invisible
*together*. No promises, but it's free to try it.

Robin S.
-------------------------
> Visual Studio 2005 / FX 2.0
>
[quoted text clipped - 8 lines]
>
> - Joe Geretz -
Earl - 25 Dec 2006 07:57 GMT
Here is what I found in your stocking today:

Probably the easiest technique is to set MappingType to Hidden on either the
dataset or the datatable BEFORE binding to the grid:

ds.YourTable.YourIDColumn.ColumnMapping = MappingType.Hidden;
-OR-

dt.Columns["YourID"].ColumnMapping = MappingType.Hidden;

> Visual Studio 2005 / FX 2.0
>
[quoted text clipped - 8 lines]
>
> - Joe Geretz -
Joseph Geretz - 28 Dec 2006 00:33 GMT
Thanks guys for your responses.

I played around with this a bit. It seems that the *first* column in the
grid can't be rendered invisible? Does that sound up to spec? I found that
simply shifting the column down to the second position caused it to go
invisible as defined. Then I tried to make the new column in the number one
position invisible, and found that it wouldn't cooperate.

Is this the defined behavior? Grid column #1 must be visible? In any case,
easy enough to work around.

Thanks,

- Joe Geretz -

> Visual Studio 2005 / FX 2.0
>
[quoted text clipped - 8 lines]
>
> - Joe Geretz -
Earl - 28 Dec 2006 01:01 GMT
Nope, it should not work that way. If you hide the column in the table, it
should not appear anywhere. If you are still showing columns after using the
MappingType.Hidden, that would tell me that you are doing a binding before
you set the Hidden property.

> Thanks guys for your responses.
>
[quoted text clipped - 23 lines]
>>
>> - Joe Geretz -
Joseph Geretz - 28 Dec 2006 03:15 GMT
Hi Earl,

What do you mean when you say 'hide the column in the table'? I'm not hiding
the column in the table; I'm setting Visible=False in the corresponding
column in the bound Grid.

Thanks,

- Joe Geretz -

> Nope, it should not work that way. If you hide the column in the table, it
> should not appear anywhere. If you are still showing columns after using
[quoted text clipped - 28 lines]
>>>
>>> - Joe Geretz -
Earl - 28 Dec 2006 06:13 GMT
As I noted in the earlier post, I'm referring to using MappingType.Hidden.
This allows you to hide the column on the dataset or datatable so it does
not appear when you bind the source to the grid.

> Hi Earl,
>
[quoted text clipped - 38 lines]
>>>>
>>>> - Joe Geretz -

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.