Cell/Column Index for DataGridView versus DataTable?

Posted on 2014-11-26
Last Modified: 2014-11-26
For a DataGridView AND DataTable...does the column index always start with zero?
Question by:BlakeMcKenna
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
  • 5
  • 2
LVL 40

Accepted Solution

Kyle Abrahams earned 500 total points
ID: 40467168
Yes it does . . . BUT note that they don't necessarily match (EG: sorting).

Author Closing Comment

ID: 40467191
I thought so...just wanted to be sure!

Thanks Kyle

Author Comment

ID: 40467203

I did notice one thing in my DGV. I have several cells that are Invisible and noticed that it affects the column index.

For example, my dgv has 10 columns (0 - 9 index). Column 0 - 3 are Invisible. The initial value in column 11 is 73.6. After the dgv is setup (making columns 0 - 3 invisible), the value 73.6 is not in column 7.

Is there a way to maintain values and column indexes even though certain dgv columns are invisible?
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.


Author Comment

ID: 40467206
The reason I ask is because my CellFormatting Even references the "e.ColumnIndex". This is where the column indexes are different.
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40467316
There's something else going on there . . .   you can set the visible property on the indexed column itself:

Do you have auto generate columns set to false?

Author Comment

ID: 40467381
AutoGenerateColumns isn't set, which I assume defaults to False...

Author Comment

ID: 40467385
I actually execute a procedure that defines the DGV.DataPropertyName (which is the same as the DataTable Column Names) and HeaderText...

Featured Post

Technology Partners: 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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 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