Solved

Cell/Column Index for DataGridView versus DataTable?

Posted on 2014-11-26
7
102 Views
Last Modified: 2014-11-26
For a DataGridView AND DataTable...does the column index always start with zero?
0
Comment
Question by:BlakeMcKenna
  • 5
  • 2
7 Comments
 
LVL 40

Accepted Solution

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

Author Closing Comment

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

Thanks Kyle
0
 

Author Comment

by:BlakeMcKenna
ID: 40467203
Kyle,

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?
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:BlakeMcKenna
ID: 40467206
The reason I ask is because my CellFormatting Even references the "e.ColumnIndex". This is where the column indexes are different.
0
 
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:
http://msdn.microsoft.com/en-us/library/bb383893%28v=vs.90%29.aspx

Do you have auto generate columns set to false?
0
 

Author Comment

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

Author Comment

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

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 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