473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Data grid problem

121 100+
Hi
I have a datagrid in my form where it is used to viw the contents of table hich has 10 fields.
now i want some columns of datagrid to be visible as false
in vb we code it has
datagrid1.columns(1).visible =false
how to code it in vb,.net 2003
can anyone help
May 29 '08 #1
4 982
shweta123
692 Expert 512MB
Hi,

You can use this code for making some coumns invisible in datagrid :
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim ts As New DataGridTableStyle
  3.         ''Name of the table to be mapped from dataset
  4.         ts.MappingName = "table"
  5.         DataGrid1.TableStyles.Add(ts)
  6.  
  7.         Dim myTableStyle As DataGridTableStyle = DataGrid1.TableStyles(0)
  8.         Dim mycolumns As GridColumnStylesCollection
  9.  
  10.         ' Get the GridColumnStylesCollection of Data Grid.
  11.         mycolumns = myTableStyle.GridColumnStyles
  12.         Dim i As Integer
  13.  
  14.         ' Remove the CustName ColumnStyle from the data grid.
  15.         If mycolumns.Contains("columnName") Then
  16.             Dim myDataColumnStyle As DataGridColumnStyle = mycolumns("columnName")
  17.             i = mycolumns.IndexOf(myDataColumnStyle)
  18.             mycolumns.RemoveAt(i)
  19.         End If
  20.     End Sub 'RemoveColumnStyle_Clicked
Hi
I have a datagrid in my form where it is used to viw the contents of table hich has 10 fields.
now i want some columns of datagrid to be visible as false
in vb we code it has
datagrid1.columns(1).visible =false
how to code it in vb,.net 2003
can anyone help
May 29 '08 #2
charvi
121 100+
Hi,

You can use this code for making some coumns invisible in datagrid :
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim ts As New DataGridTableStyle
  3.         ''Name of the table to be mapped from dataset
  4.         ts.MappingName = "table"
  5.         DataGrid1.TableStyles.Add(ts)
  6.  
  7.         Dim myTableStyle As DataGridTableStyle = DataGrid1.TableStyles(0)
  8.         Dim mycolumns As GridColumnStylesCollection
  9.  
  10.         ' Get the GridColumnStylesCollection of Data Grid.
  11.         mycolumns = myTableStyle.GridColumnStyles
  12.         Dim i As Integer
  13.  
  14.         ' Remove the CustName ColumnStyle from the data grid.
  15.         If mycolumns.Contains("columnName") Then
  16.             Dim myDataColumnStyle As DataGridColumnStyle = mycolumns("columnName")
  17.             i = mycolumns.IndexOf(myDataColumnStyle)
  18.             mycolumns.RemoveAt(i)
  19.         End If
  20.     End Sub 'RemoveColumnStyle_Clicked




Hi
i used this code but my problem is not solved
can any one suggest how to make some column of datagrid in vb.net in visible at form load
Jun 1 '08 #3
charvi
121 100+
Hi
i used this code but my problem is not solved
can any one suggest how to make some column of datagrid in vb.net in visible at form load

--------------------------------------------------------------------------------
Jun 1 '08 #4
shweta123
692 Expert 512MB
Hi,

What error are you getting? Can you post all your code so that we can help you?
Jun 2 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jordan O'Hare | last post by:
Hello Everyone, I am after some help with the following: I have a windows application that contains a list box and two data grids. All three controls are binded to a dataset that contains...
2
by: kk | last post by:
Have 2 problems, any help is appreciated. Tab with Grids -------------- BL - fetching data from DB ( 5 secs - 10 rows) Grid Laod - 20 secs Grid Paint on tab change - 20 secs Problem: The...
1
by: Da-Breegster | last post by:
Hi. I'm attempting to write a roguelike (think nethack, crawl, angband, tome, adom, and yes, I suppose even rogue) in Perl and I've ran into a problem regarding the data structure for the map and...
1
by: Rushabh Dadbhawala | last post by:
Problem: I am fetching data from the database, storing it in a dataSet, and binding it with a Data Grid. The DataGrid controls allows sorting. The problem is that when the data is sorted on one...
2
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is...
7
by: Richard | last post by:
If the grid is dragged off the screen and back on the data is visible. Tried a dg.refresh() and Inactivate(). Can I do this by overriding custom base class OnPaint that my form inherits from? I...
3
by: pmud | last post by:
Hi, I have a web page (asp.net, code:c#). I havean html table with text boxes. Based on the user input , records are displayed in the data grid below it. Now the datagrid has a large no. of...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...
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,...

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.