Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView Column Indexes all return 0

Status
Not open for further replies.

ousoonerjoe

Programmer
Jun 12, 2007
925
0
0
US
Using Vb.Net 2010 SP1

I have encountered this a few times now and for the life of me do not understand what is happening or why. I have a DataGridView named dgParts. It has multiple columns (with prefix of "dc") associated with it. I used the GUI interface to create it all. At run time the column.Index = 0 for ALL columns. When I use the column name, it works just fine.

Below is a sample of the code from the dgParts_RowEnter Event:
Code:
                chkActive.Checked = dgParts.Item(dcActive.Index, e.RowIndex).Value
                txtDesc.Text = dgParts.Item(dcDescription.Index, e.RowIndex).Value
                cmbDivisionId.SelectedValue = dgParts.Item(dcDivisionId.Index, e.RowIndex).Value

Any suggestions or explanations are welcome. It seems to be intermittent. Not all forms with a DGV have this issue.

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top