If you add a SelectedValue changed eventhandler to your sample, and place a stop in it, you can track the selected index first being zero, then changing to -1 (as you explicitly set it), and then see it being reset to zero later. This last change that undoes the -1 setting is being triggerred by the OnBindingContextChanged event that occurs when the control is reparented. The point here is that grid is not really forcing the selection to be zero, but instead is responding to the selection being changed to zero down in the framework ListControl.OnBindingContextChanged code. I do not know that the grid can have anyway of directly determining whether it should respond to the base class changing the index or not. I think, in general, the grid has to actually set the index to what the baseclass ListControl indicates in this situation.
But the GridListControl does have the option of not calling the base class in an override of this OnBindingCOntextChnaged. And this would prevent the baseclass from changing the index at this point.
public class MyGridListControl : GridListControl
{
protected override void OnBindingContextChanged(EventArgs e)
{
//dont call base class
//base.OnBindingContextChanged (e);
}
}
The above override worked in the sample to avoid resetting the -1. Now, I did not use .NET Reflector to see what might be being missed (if anything) by not calling the baseclass. So, if you use this override, you probably should take a look to check if you need to add other code to your override.