473,789 Members | 2,926 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 1847
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
1883
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 way to do it, because there is no Visible property available...).
1
1569
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 visible property of the corresponding fields to true. So far so good...BUT I want to compact the...
3
6826
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 displays an event for update (frmEventAdd). Then clicks on a button to display the Trials for that event...
3
2163
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
1739
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
3766
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 SqlDataAdapter("select * from Authors",
4
4091
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
4904
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 submits the form. Also I can't get it to transfer the file in the upload section. The file name...
2
4267
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 main form. Any report, etc. generated will have to have the same set of records.
0
9666
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9984
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7529
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2909
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.