[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

datagridview in visual basic 2005

I am developing with Visual Basic 2005.
I need to hide an "Id"column on my datagridview.  I have the following line of code:

Dim adapter As New OleDbDataAdapter("select * from Clients", conn).  There are several columns that I do not want to be shown but my main concern is the "ID" column.

How do I hide ID column from the datagridview.
thanks
0
systems_ax
Asked:
systems_ax
  • 4
  • 2
1 Solution
 
Jorge PaulinoIT Pro/DeveloperCommented:
Do you populate the datagridview on runtime or on design mode ?
0
 
systems_axAuthor Commented:
I populate it in runtime like this:

  Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents and Settings\Admin\Desktop\Test.mdb")
 Dim adapter As New OleDbDataAdapter("select * from Clients", conn)

        Dim dt As New DataTable("Clients")
        adapter.Fill(dt)
        dgvLastNames.DataSource = dt

I have a button that when pressed pulls all the columns from access.
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Ok, after you populate the datagridview you can do this:

Me.dgvLastNames.Columns(X).Visible = False

where X = Index or the column name
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Jorge PaulinoIT Pro/DeveloperCommented:
Also you can change the SQL statement without include the ID

Dim adapter As New OleDbDataAdapter("select field1,field2,field3,field4 from Clients", conn)
0
 
systems_axAuthor Commented:
thank you so much, it worked
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Glad I could help!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now