473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataGridView columns

Hi,

I have a DataGridView control, and I am using it's datasource property
to assign a datatable to it at runtime.
The datatable has some columns in it that I don't want to be visible.

With the DataGrid control in .Net 1, each Column had a property that
allowed it to be bound to a column in a datatable, so I could define the
columns of the grid, and which columns they related to in its
datasource, and they were all that would display.

Is there an equivalent in the DataGridView, or another way to achieve this?
Thanks.
Paul Cheetham
May 21 '06 #1
3 2857
You can either set their Visible properties to false, or remove them from
the DataGridView Columns Collection.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.

"Paul Cheetham" <PA******@dsl.pipex.com> wrote in message
news:eh**************@TK2MSFTNGP03.phx.gbl...
Hi,

I have a DataGridView control, and I am using it's datasource property to
assign a datatable to it at runtime.
The datatable has some columns in it that I don't want to be visible.

With the DataGrid control in .Net 1, each Column had a property that
allowed it to be bound to a column in a datatable, so I could define the
columns of the grid, and which columns they related to in its datasource,
and they were all that would display.

Is there an equivalent in the DataGridView, or another way to achieve
this?
Thanks.
Paul Cheetham

May 21 '06 #2

So I can only do it after I have bound a datasource to the Dategridview?
Which presumably means that every time I re-load the data, I have to
remove the columns I don't want.

It seems a much less elegant way of doing it than the method the
Datagrid used.
Paul
Kevin Spencer wrote:
You can either set their Visible properties to false, or remove them from
the DataGridView Columns Collection.

May 21 '06 #3
You only have to do it the first time you create the DataGridView. After
that, you can update it, add and remove rows, etc, without modification.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.

"Paul Cheetham" <PA******@dsl.pipex.com> wrote in message
news:ur**************@TK2MSFTNGP03.phx.gbl...

So I can only do it after I have bound a datasource to the Dategridview?
Which presumably means that every time I re-load the data, I have to
remove the columns I don't want.

It seems a much less elegant way of doing it than the method the Datagrid
used.
Paul
Kevin Spencer wrote:
You can either set their Visible properties to false, or remove them from
the DataGridView Columns Collection.

May 21 '06 #4

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

Similar topics

4
by: Stropher | last post by:
I have the following: this.dataGridViewBill.DataSource = tblResult; //hide the following columns this.dataGridViewBill.Columns.Visible = false; //email this.dataGridViewBill.Columns.Visible =...
3
by: Art | last post by:
Hi, Forgive me for posting this message in 2 groups -- it appears that the Data Access group isn't very active, so I'm posting again here: I have a DataTable that I want to fill using a...
3
by: Rich | last post by:
Hello, I am populating a datagridview from a datatable and filtering the number of rows with a dataview object. Is there a way to retrieve the rows displayed by the datagridview into a separate...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
3
by: connected | last post by:
I'm having difficulty with populating a DataGridView control with data correctly. It works with a single class, for example... class MyClass { private string _propertyOne; private string...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
9
by: trint | last post by:
How can I retrieve all of the data from a datagridview? Any help is appreciated. Thanks, Trint
1
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:...
6
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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,...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.