I wrote some code that would allow me to reorder columns by dragging and dropping the LabelPresenters around. In a simple application it works flawlessly. However, in a more involved grid, I get a weird effect. When I drop a field onto another, it easily moves it and all. But when the grid redraws, most of my cells become blank; the values are just gone! The Cell.Value property is empty. The weirdest thing is that the fields for which values are missing are always the same, and, for the life of me, I can't find anything different about the fields that work.
The code that does the moving of the fields is:
DragDropDataObject dataObj = e.Data.GetData(typeof(object)) as DragDropDataObject;
if (dataObj == null) return;
Field fieldDroppedOn = droppedOn.Field;
Field droppedField = layout.Fields[dataObj.FieldName];
if (droppedField == null || droppedOn == null) return;
int fieldIndex = layout.Fields.IndexOf(fieldDroppedOn);
layout.Fields.Remove(droppedField);
layout.Fields.Insert(fieldIndex, droppedField);
I am having a really hard time replicating this issu. Is there any limitations with removing/adding fields to the active field layout that I should be aware of?
I have attached a screen shot of the blank cells.