I wish to display, in a datagrid, only six columns of a table containing
about twenty. I've created a data adapter which selects only the desired
columns. I created a dataset and a dataview, and specified the dataview as
the data source for my datagrid.

The datagrid displays the 6 desired columns, in the sequence that I selected
them, followed by the remaning 14. I read someplace that this is the
default behavior.

Two questions:

(1) How do I hide the unwanted 14 coulumns?
(2) How can I change the column headings to something other than the column
name of the underlying table?

Thanks, Phil

raincounty<*>hotmail.com -- replace the <*> with you know what

Re: Hiding columns in a data grid (.net, c#) by Cor

Cor
Sat Nov 26 03:40:47 CST 2005

Rain,

First a queston if you have "selected" 6 columns how can there than be 20
columns in your datatable.

The datagrid can only show what is in the datatable.

In otherwords what do you mean by *selected*.

Tell us as well if you are using 2003 or 2005, the dataview can select
columns in the 2005 version.

Cor



Re: Hiding columns in a data grid (.net, c#) by Paul

Paul
Sat Nov 26 03:44:30 CST 2005


One option is to add a TableStyle to your datagrid in which you can
configure the visible column and column headers. See this article
Customizing the Windows Forms DataGrid
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_custdatagrid.asp.

For a more dynamic behavior you can set the Visible property during runtime
grid.Columns[index].Visible = false;

Another option is to disable the "Create Columns automatically at runtime"
via the Property Builder by right clicking the datagrid.

###
Best regards,
Paul Gielens

Visit my blog @ http://weblogs.asp.net/pgielens/

"Rain County" <raincounty-at-hotmail> wrote in message
news:u9GvDji8FHA.472@TK2MSFTNGP15.phx.gbl...
>
> I wish to display, in a datagrid, only six columns of a table containing
> about twenty. I've created a data adapter which selects only the desired
> columns. I created a dataset and a dataview, and specified the dataview
> as the data source for my datagrid.
>
> The datagrid displays the 6 desired columns, in the sequence that I
> selected them, followed by the remaning 14. I read someplace that this is
> the default behavior.
>
> Two questions:
>
> (1) How do I hide the unwanted 14 coulumns?
> (2) How can I change the column headings to something other than the
> column name of the underlying table?
>
> Thanks, Phil
>
> raincounty<*>hotmail.com -- replace the <*> with you know what
>
>




Re: Hiding columns in a data grid (.net, c#) by Rain

Rain
Sat Nov 26 15:16:59 CST 2005

Cor, thanks for the reply.

By 'selected', I mean that the SELECT statement in my OleDbDataAdapter
specifies 6 columns instead of all (*). I am still using VS 2003, and in
case it is pertinent, my data source is an Access table.


Phil


"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:%23cLQh2m8FHA.3752@tk2msftngp13.phx.gbl...
> Rain,
>
> First a queston if you have "selected" 6 columns how can there than be 20
> columns in your datatable.
>
> The datagrid can only show what is in the datatable.
>
> In otherwords what do you mean by *selected*.
>
> Tell us as well if you are using 2003 or 2005, the dataview can select
> columns in the 2005 version.
>
> Cor
>



Re: Hiding columns in a data grid (.net, c#) by Rain

Rain
Sat Nov 26 15:18:21 CST 2005

Thanks Paul,

I should mention that I am using VS 2003, and that my data source is a table
in an Access mdb.

I am now studying the article you referred me to below. Hopefully
DataGridTableStyle will provide what I need.

I tried your second suggestion and got: "'System.Windows.Forms.DataGrid'
does not contain a definition for 'Columns'". Is that property available in
2003? Is it available for web pages only?

As to the Property Builder, I can't find it. Is that available for Windows
Forms, or is it just a web page thing?

Phil

"Paul Gielens" <pgielens@gmail.com.nospam> wrote in message
news:ezZxJ4m8FHA.808@TK2MSFTNGP09.phx.gbl...
>
> One option is to add a TableStyle to your datagrid in which you can
> configure the visible column and column headers. See this article
> Customizing the Windows Forms DataGrid
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_custdatagrid.asp.
>
> For a more dynamic behavior you can set the Visible property during
> runtime grid.Columns[index].Visible = false;
>
> Another option is to disable the "Create Columns automatically at runtime"
> via the Property Builder by right clicking the datagrid.
>
> ###
> Best regards,
> Paul Gielens
>
> Visit my blog @ http://weblogs.asp.net/pgielens/
>
> "Rain County" <raincounty-at-hotmail> wrote in message
> news:u9GvDji8FHA.472@TK2MSFTNGP15.phx.gbl...
>>
>> I wish to display, in a datagrid, only six columns of a table containing
>> about twenty. I've created a data adapter which selects only the desired
>> columns. I created a dataset and a dataview, and specified the dataview
>> as the data source for my datagrid.
>>
>> The datagrid displays the 6 desired columns, in the sequence that I
>> selected them, followed by the remaning 14. I read someplace that this
>> is the default behavior.
>>
>> Two questions:
>>
>> (1) How do I hide the unwanted 14 coulumns?
>> (2) How can I change the column headings to something other than the
>> column name of the underlying table?
>>
>> Thanks, Phil
>>
>> raincounty<*>hotmail.com -- replace the <*> with you know what
>>
>>
>
>
>



Re: Hiding columns -- IT WORKS by Rain

Rain
Sun Nov 27 01:07:55 CST 2005

Paul, thanks a lot. Option one, adding a table style as shown in the link
you provided works perfectly. A bit tedious, but it allows a lot of
flexibility!

Phil

"Paul Gielens" <pgielens@gmail.com.nospam> wrote in message
news:ezZxJ4m8FHA.808@TK2MSFTNGP09.phx.gbl...
>
> One option is to add a TableStyle to your datagrid in which you can
> configure the visible column and column headers. See this article
> Customizing the Windows Forms DataGrid
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_custdatagrid.asp.
>
> For a more dynamic behavior you can set the Visible property during
> runtime grid.Columns[index].Visible = false;
>
> Another option is to disable the "Create Columns automatically at runtime"
> via the Property Builder by right clicking the datagrid.
>
> ###
> Best regards,
> Paul Gielens
>
> Visit my blog @ http://weblogs.asp.net/pgielens/
>
> "Rain County" <raincounty-at-hotmail> wrote in message
> news:u9GvDji8FHA.472@TK2MSFTNGP15.phx.gbl...
>>
>> I wish to display, in a datagrid, only six columns of a table containing
>> about twenty. I've created a data adapter which selects only the desired
>> columns. I created a dataset and a dataview, and specified the dataview
>> as the data source for my datagrid.
>>
>> The datagrid displays the 6 desired columns, in the sequence that I
>> selected them, followed by the remaning 14. I read someplace that this
>> is the default behavior.
>>
>> Two questions:
>>
>> (1) How do I hide the unwanted 14 coulumns?
>> (2) How can I change the column headings to something other than the
>> column name of the underlying table?
>>
>> Thanks, Phil
>>
>> raincounty<*>hotmail.com -- replace the <*> with you know what
>>
>>
>
>
>