473,573 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make columns (fields) invisible dynamically?

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, 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.

The following Possible solution do not work:
dg.Column(3).Vi sible = false.

My analysis from the test: dg.Column(3).Vi sible = false is only working for
those columns which are defined in design by DataGrid Property Builder. If
you populate a table to the datagrid via binding programmaticall y, it does
not work, at least in my computer.

Any good solution for it?

Thanks

David
Nov 19 '05 #1
3 1841
Hi David,

The Column.Visible property works on both declaratively and dynamically
created DataGrid controls. To prove it, I put in this demo
http://www.societopia.net/Samples/Da...Delegates.aspx an experiment
in hiding/displaying columns with a dynamically created DataGrid.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"david" wrote:
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, 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.

The following Possible solution do not work:
dg.Column(3).Vi sible = false.

My analysis from the test: dg.Column(3).Vi sible = false is only working for
those columns which are defined in design by DataGrid Property Builder. If
you populate a table to the datagrid via binding programmaticall y, it does
not work, at least in my computer.

Any good solution for it?

Thanks

David

Nov 19 '05 #2
I have played your example. It is a very good example to help me for other
checkbox control of cell in a datagrid. I will check your code.

By the way, when you drag the datagrid from toolbox, have you unchecked any
property for it?

Thanks

David

"Phillip Williams" wrote:
Hi David,

The Column.Visible property works on both declaratively and dynamically
created DataGrid controls. To prove it, I put in this demo
http://www.societopia.net/Samples/Da...Delegates.aspx an experiment
in hiding/displaying columns with a dynamically created DataGrid.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"david" wrote:
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, 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.

The following Possible solution do not work:
dg.Column(3).Vi sible = false.

My analysis from the test: dg.Column(3).Vi sible = false is only working for
those columns which are defined in design by DataGrid Property Builder. If
you populate a table to the datagrid via binding programmaticall y, it does
not work, at least in my computer.

Any good solution for it?

Thanks

David

Nov 19 '05 #3
Hi David,

The example whose link I provided below was not created using the VS.Net
toolbox at all. It is done using a notepad. The controls are created
dynamically (not placed declaratively on the web form). If you want another
sample that is done declaratively (i.e. you can recreate using the VS.Net)
review this one
http://www.societopia.net/Samples/Da...olsEvents.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"david" wrote:
I have played your example. It is a very good example to help me for other
checkbox control of cell in a datagrid. I will check your code.

By the way, when you drag the datagrid from toolbox, have you unchecked any
property for it?

Thanks

David

"Phillip Williams" wrote:
Hi David,

The Column.Visible property works on both declaratively and dynamically
created DataGrid controls. To prove it, I put in this demo
http://www.societopia.net/Samples/Da...Delegates.aspx an experiment
in hiding/displaying columns with a dynamically created DataGrid.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"david" wrote:
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, 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.

The following Possible solution do not work:
dg.Column(3).Vi sible = false.

My analysis from the test: dg.Column(3).Vi sible = false is only working for
those columns which are defined in design by DataGrid Property Builder. If
you populate a table to the datagrid via binding programmaticall y, it does
not work, at least in my computer.

Any good solution for it?

Thanks

David

Nov 19 '05 #4

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

Similar topics

3
1870
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 tablestyle and gridcolumnstyles to that tablestyle. If we have invisible columns, we add the gridcolumnstyle with Width = 0 (couldn't find any other...
1
1562
by: Laertes | last post by:
HI, is it there a possibility of selecting which fields to have visible on a form? Up to now I've setup another form which has true/false toggles (one for each field in question) on which I select which fields I want visible. Then when I open the form in question the "openform" subroutine checks which toggles have true values and sets the...
3
6818
by: Susan Bricker | last post by:
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is frmTrialInfo. Each Trial can have three Classes. The third form is frmClassInfo. These forms are used for update and adding new records. The user...
3
2154
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 kinda stuck there. but this is basicly what i want. if Username = "Deleted_User" then 'make entire table row invisible. End if
2
1732
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 = "ParentTable" DataGridLedger.DataBind() DataGridLedger.Visible = True DataGridLedger.Columns(1).Visible = False
15
3750
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. How do i hide a column? Thanks. MyConnection = New SqlConnection("server=(local);database=pubs;Trusted_Connection=yes") MyCommand = New...
4
4079
by: david | last post by:
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
6
4856
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still...
2
4248
by: ghat12 | last post by:
Hi, I am trying to print a subform containing approx 50 columns in datasheet view. The printout cannot fit more than 8-10 columns. Does anyone know of any way to print all columns; i don't care if the printout spans multiple pages. FYI, the records displayed in the sub-form are dynamically obtained based on some ad-hoc querying in the...
0
7781
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7699
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8027
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8066
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6421
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5292
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3733
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2216
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 we have to send another system
1
1304
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.