Solved

Get DataGridView Column Name

Posted on 2008-06-11
2
4,521 Views
Last Modified: 2013-11-07
Hi,
How do i get the 'name' of a DataGridView Column?

Ive tried:
Dim myColumn as DataGridViewColumn
myColumn = DataGridView.Column.Item("Column Name")

No such luck!
0
Comment
Question by:hqpsystems
2 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 21761032
Try below.

dataGridView.Columns[0].Name ' change the columns index to get appropriate name
0
 
LVL 14

Accepted Solution

by:
rachitkohli earned 50 total points
ID: 21768206
dataGridView1.Columns(0).Name will give you the column name

but based on a cell, if you want a column name, use :
DataGridView1.Columns(DataGridView1.Item(2, 1).ColumnIndex).Name
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

713 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