Solved

Get DataGridView Column Name

Posted on 2008-06-11
2
4,537 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 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

623 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