Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get DataGridView Column Name

Posted on 2008-06-11
2
Medium Priority
?
4,550 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 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

971 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