473,506 Members | 17,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make some columns invisible in DataGrid dynamically

I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

Anyone can tell how to do it?

Thanks

David
Nov 19 '05 #1
4 4071
You should be able to access each column's visible property like so:

dgDataGrid.Columns(3).visible = false

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"david" <da***@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and
use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

Anyone can tell how to do it?

Thanks

David

Nov 19 '05 #2
David,

Use the datagrid's OnItemDatabound event.

I have some code on my website for adding a checkbox to a datagrid
dynamically that would be a way for you to become familiar with the
OnItemDatabound event. If you'd like to take a look at it you may find it by
using the search box on this page:
http://www.aboutfortunate.com?page=codelibrary to search for "Checkbox in
Datagrid"

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"david" <da***@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and
use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

Anyone can tell how to do it?

Thanks

David

Nov 19 '05 #3
Thank you, David Lozzi and Justin Gengo:
I will try it.
I would be interested in OnItemDatabound event as well, since I did someting
in part which is related to this topic.

David

"S. Justin Gengo" wrote:
David,

Use the datagrid's OnItemDatabound event.

I have some code on my website for adding a checkbox to a datagrid
dynamically that would be a way for you to become familiar with the
OnItemDatabound event. If you'd like to take a look at it you may find it by
using the search box on this page:
http://www.aboutfortunate.com?page=codelibrary to search for "Checkbox in
Datagrid"

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"david" <da***@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and
use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

Anyone can tell how to do it?

Thanks

David


Nov 19 '05 #4
Hi, David Lozzi:

dgDataGrid.Columns(3).visible = false

is only working for the selected columns in DataGrid Property Builder in
design.

I have tried dgDataGrid.Itemss(3).visible = false. But it does not work.

"David Lozzi" wrote:
You should be able to access each column's visible property like so:

dgDataGrid.Columns(3).visible = false

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"david" <da***@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and
use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

Anyone can tell how to do it?

Thanks

David


Nov 19 '05 #5

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

Similar topics

3
1863
by: Igor Mendizabal | last post by:
Hello, We're doing our own datagrid based on the System.windows.forms.datagrid control, and are having some problems with horizontal scrolling. In general, we construct our datagrid adding a...
3
2529
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
0
2257
by: Bob | last post by:
I have a data grid with a template column. Sometimes I need this column to be read-only, even in edit mode. Does anyone know how to do this. I get the other columns by running through the...
6
2428
by: John Ruiz | last post by:
Greetings, I originally posted this to microsoft.public.dotnet.framework.aspnet.datagridcontrol two weeks ago, but no one was able to answer. I am unable to dynamically add columns to a...
8
7304
by: Hanson | last post by:
I have a datagrid control in an aspx page. The datagrid columns will be dynamically generated according to the pre-page's search condition, I want to hide some columns in the datagrid. is that...
3
2147
by: Richard | last post by:
After printing a userlist to a Datagrid i want some names not to be shown. I want to know how i can make a entire datagrid row invisible. I suspect its something with the OnItemDatabound but i am...
2
1726
by: Michael Chong | last post by:
Hi, How can I make a column in Datagrid invisible programmatically during run-time? I did try the following but doesn't work. DataGridLedger.DataSource = myDataSet DataGridLedger.DataMember =...
15
3737
by: John Blair | last post by:
Hi, Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist....
3
1837
by: david | last post by:
I have posted my question before. It seems that I can not find the solution. The question: I have datasource, say, ds which is bounded to a datagrid, dg. Assume that ds have 5 columns,...
0
7105
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
7308
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,...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5617
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,...
1
5037
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...
0
4702
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
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
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...

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.