[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Datagridview hidden column still visible

Posted on 2009-04-29
4
Medium Priority
?
513 Views
Last Modified: 2012-06-22
I have a hidden column in a datagridview that is still barely showing on the left hand side. I have uploaded an image of it. You can see it barely shows and if you mousehover it the data in it shows. I need to have this data stored with the hidden column, but I dont want the user to have any access to it.
I am hiding the column like this:
            .Columns(0).Width = 0
            .Columns(0).Visible = False

Image, The red arrow points to the row that shows slightly:
http://img524.imageshack.us/img524/3593/56723883.jpg

How can I hide this row so it is not seen at all?
With Me.datagridview1
            .DataSource = ds.Tables(0)
            .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None
            .Columns(0).Width = 0
            .Columns(0).Visible = False
            .Columns(1).Width = 45
            .Columns(1).Name = "Year"
            .Columns(1).HeaderText = "Year"
            .Columns(2).Width = 0
            .Columns(2).Visible = False
            .Columns(3).Width = 745
            .Columns(3).Name = "ProjectTitle"
            .Columns(3).HeaderText = "Project Title"
        End With

Open in new window

0
Comment
Question by:bertino12
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24261486
Can you show us the DataGrid definition please (ASP.NET code)?
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24261533
Sorry, i didn't noticed it was not ASP.NET.  

Have you tried to modify the Columns collection from the designer?  Hide the columns that you want.  It work for me...
0
 

Author Comment

by:bertino12
ID: 24261574
I programmatically added the columns. I will try to create them in the designer.
0
 

Accepted Solution

by:
bertino12 earned 0 total points
ID: 24261755
I really need to bind this thing on the fly instead of through the designer. I found this and it fixed the problem.

To hide a CustomerID column that is automatically generated during data binding, place the following code example in a DataBindingComplete event handler.

I posted the solution below.
    Private Sub DataGridView1_DataBindingComplete(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles DataGridView1.DataBindingComplete
        With sender
            .Columns(0).Visible = False
            .Columns(1).Width = 45
            .Columns(1).Name = "Year"
            .Columns(1).HeaderText = "Year"
            .Columns(2).Visible = False
            .Columns(3).Width = 745
            .Columns(3).Name = "ProjectTitle"
            .Columns(3).HeaderText = "Project Title"
        End With
    End Sub

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question