PC Review


Reply
Thread Tools Rate Thread

Can't Make Primary Key Column Invisible in DataGrid?

 
 
Joseph Geretz
Guest
Posts: n/a
 
      25th Dec 2006
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 -


 
Reply With Quote
 
 
 
 
RobinS
Guest
Posts: n/a
 
      25th Dec 2006
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.
-------------------------
"Joseph Geretz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 -
>



 
Reply With Quote
 
Earl
Guest
Posts: n/a
 
      25th Dec 2006
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;

"Joseph Geretz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 -
>



 
Reply With Quote
 
Joseph Geretz
Guest
Posts: n/a
 
      28th Dec 2006
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 -

"Joseph Geretz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 -
>



 
Reply With Quote
 
Earl
Guest
Posts: n/a
 
      28th Dec 2006
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.

"Joseph Geretz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 -
>
> "Joseph Geretz" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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 -
>>

>
>



 
Reply With Quote
 
Joseph Geretz
Guest
Posts: n/a
 
      28th Dec 2006
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 -

"Earl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
> "Joseph Geretz" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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 -
>>
>> "Joseph Geretz" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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 -
>>>

>>
>>

>
>



 
Reply With Quote
 
Earl
Guest
Posts: n/a
 
      28th Dec 2006
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.

"Joseph Geretz" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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 -
>
> "Earl" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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.
>>
>> "Joseph Geretz" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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 -
>>>
>>> "Joseph Geretz" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> 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 -
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make multiple datagrid rows invisible?? Nader Microsoft Dot NET 0 10th Nov 2006 12:04 PM
Any way to make the last null row of datagrid invisible? greg chu Microsoft VB .NET 1 20th Apr 2005 04:59 PM
How do a make an <ASP:DataGrid column invisible when its data bound? John Blair Microsoft ASP .NET 15 3rd Jan 2005 04:06 AM
DataGrid Column Make Invisible Michael Chong Microsoft ASP .NET 2 16th Oct 2004 03:59 AM
How Do I Make a Column In My Bound DataGrid Invisible? Ben Pursley Microsoft VB .NET 3 16th Sep 2003 09:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:56 AM.