Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / April 2007

Tip: Looking for answers? Try searching our database.

can datagrid column hidden in vb.net ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Localbar - 12 Apr 2007 08:12 GMT
hi all,

   If I have a datagrid, actually has 5 column. but I would like in run
time hidden last column.
   The reason is the form also have combobox for filter datagrid row. my
problem is that I don't want the filter key show in datagrid. so that's why
I would like to hidden it...any idea..

Thanks
ClayB - 12 Apr 2007 09:54 GMT
Is this a Windows Forms DataGrid? If so, you can set the column width
to zero to hide a column provided you have a non-Nothing tablestyle.
Here is some code snippets.

'.... make sure your DataGrid is using a tablestyle
dataGrid1.DataSource = _dataSet.Tables("customers")
Dim dgts As New DataGridTableStyle()
dgts.MappingName = "customers"
dataGrid1.TableStyles.Add(dgts)

'......

'method to set a column with by colnumber
Public Sub SetColWidth(tableStyle As DataGridTableStyle, colNum As
Integer, width As Integer)
  Try
     tableStyle.GridColumnStyles(colNum).Width = width
     tableStyle.DataGrid.Refresh()
  Catch 'empty catch .. do nothing
  End Try
End Sub 'SetColWidth

'....

' here is how you might call this method
Private Sub button1_Click(sender As Object, e As System.EventArgs)
  Dim tableStyle As DataGridTableStyle =
dataGrid1.TableStyles("customers")
  SetColWidth(tableStyle, 1, 0) 'set width to zero
End Sub 'button1_Click

===============
Clay Burch
Syncfusion, Inc.
Wayne Pedersen - 12 Apr 2007 14:38 GMT
In the designer (or via code) you can toggle the columns Visible
property off.

HTH,

Wayne P.

> Is this a Windows Forms DataGrid? If so, you can set the column width
> to zero to hide a column provided you have a non-Nothing tablestyle.
[quoted text clipped - 30 lines]
> Clay Burch
> Syncfusion, Inc.
Localbar - 13 Apr 2007 04:59 GMT
Thanks
I try it also ok..

> In the designer (or via code) you can toggle the columns Visible
> property off.
[quoted text clipped - 37 lines]
> > Clay Burch
> > Syncfusion, Inc.
Localbar - 13 Apr 2007 04:59 GMT
now is ok...
Thanks Clay

> Is this a Windows Forms DataGrid? If so, you can set the column width
> to zero to hide a column provided you have a non-Nothing tablestyle.
[quoted text clipped - 30 lines]
> Clay Burch
> Syncfusion, Inc.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.