?
Solved

Get DataGridView Column Name

Posted on 2008-06-11
2
Medium Priority
?
4,546 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 150 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

Industry Leaders: 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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

719 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