Solved

Cell/Column Index for DataGridView versus DataTable?

Posted on 2014-11-26
7
101 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now