• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 114
  • Last Modified:

Cell/Column Index for DataGridView versus DataTable?

For a DataGridView AND DataTable...does the column index always start with zero?
0
BlakeMcKenna
Asked:
BlakeMcKenna
  • 5
  • 2
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
Yes it does . . . BUT note that they don't necessarily match (EG: sorting).
0
 
BlakeMcKennaAuthor Commented:
I thought so...just wanted to be sure!

Thanks Kyle
0
 
BlakeMcKennaAuthor Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
BlakeMcKennaAuthor Commented:
The reason I ask is because my CellFormatting Even references the "e.ColumnIndex". This is where the column indexes are different.
0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
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
 
BlakeMcKennaAuthor Commented:
AutoGenerateColumns isn't set, which I assume defaults to False...
0
 
BlakeMcKennaAuthor Commented:
I actually execute a procedure that defines the DGV.DataPropertyName (which is the same as the DataTable Column Names) and HeaderText...
0

Featured Post

Industry Leaders: 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!

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now