tags:

views:

57

answers:

1

I'd like to be able to remove and re-insert columns in a last-removed-first-reinserted fashion, but the ListViewItem.SubItems[] values get messed up if more than 1 column is removed.

For example,

A B C D A0 B0 C0 D0

If I remove B, then B0 disappears, as expected. When I re-insert B, B0 re-appears in the correct location, between A0 and C0.

However, if I remove B, then C, then re-insert C; then B0 appears in the C column, C0 in the D column, and D0 is missing.

Any ideas on how I can get the behavior that I want?

Thanks!

A: 

The trick is to use fakery whenever possible. Hide the columns, don't remove them. You hide a column by setting its width to 0.

Otherwise, move your data to using an actual grid of some sort.

Chris Brandsma
Yeah, switching to a DataGridView is on my todo list :)
Christopher