Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How can I reorder DataGridView Columns correctly? DisplayIndex is not working properly.

$
0
0

I've been slamming my head against the wall for too long on this problem.  I've tried almost everything. 

I set specific columns like so:

dgvPrograms.Columns["BenefitYear"].DisplayIndex = 0

dgvPrograms.Columns["Eligible"].DisplayIndex = 1

dgvPrograms.Columns["TransactionSourceCode"].DisplayIndex = 2

dgvPrograms.Columns["TransactionSourceName"].DisplayIndex = 3

dgvPrograms.Columns["OutstandingAmount"].DisplayIndex = 4

dgvPrograms.Columns["ClaimedAmount"].DisplayIndex = 5

Which is all fine and dandy, however the OutstandingAmount column appears in the wrong spot.  When I run the application, the ACTUAL order of the colums is:

BenefitYear, OutstandingAmount, Eligible, TransactionSourceCode, TransactionSourceName, Claimed Amount.

Which makes no sense!  because if I print out the columns of the datagridview I get the following which are in the correct order!

TableRow has display index of 19
EntitlementID has display index of 18
BenefitConfigurationID has display index of 17
BCMAID has display index of 16
EntitlementAmount has display index of 15
ServiceYears has display index of 14
Eligible has display index of 1
ExternalReferenceID has display index of 13
TransactionSourceID has display index of 12
TransactionSourceCode has display index of 2
TransactionSourceName has display index of 3
BenefitYear has display index of 0
IndividualName has display index of 11
PayeeName has display index of 10
ClaimedAmount has display index of 5
PaidAmount has display index of 7
AdminFeesAmount has display index of 6
OutstandingAmount has display index of 4
AdjustmentReason has display index of 9
ForfeitAmount has display index of 8

No idea what to do next, I've tried it all. 

Any help would be greatly appreciated!


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>