Solved

Cell/Column Index for DataGridView versus DataTable?

Posted on 2014-11-26
7
104 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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 …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 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