G
Guest
I have a ListControl on a TabPage. It doesn't matter which ListControl as
I've tried ListBox, ComboBox, and as shown below a custom derived control (in
fact the RadioButtonList control described in a July 2004 MSDN article). Here
is a sequence of happenings that is giving me grief:
1) I select an item that is not the first item in the ListControl and which
is not the currently selected item
2) I tab out of the ListControl
3) The property to which the ListControl's SelectedValue is bound is updated
4) The bound object raises a PropertyChanged event, initating a sequence of
ListChanged events
5) Ultimately, the ListControl.SelectedIndex property is set to 0 and the
top item in the ListControl shows as the selected item
If I change a property on another control on the TabPage then the
ListControl changes to show the correct selected item (the one selected in
step 1 above). Thereafter, the ListControl will show the correct selected
item as it is changed.
Here's a stack trace at the moment the SelectedIndex is being set to 0. The
line at the bottom of the stack trace shows the property bound to the
SelectedValue property of the ListControl being set to 2 which corresponds to
a SelectedIndex value of 1. The top line in the trace shows the SelectedIndex
value being incorrectly set to 0.
UI.dll!UI.ListControl.SelectedIndex.set(int value = 0)
System.Windows.Forms.dll!System.Windows.Forms.ListControl.DataManager_PositionChanged(object sender, System.EventArgs e)
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnPositionChanged(System.EventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordState(int
newPosition, bool validating, bool endCurrentEdit, bool firePositionChange,
bool pullData)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.Position.set(int value)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.ParentCurrencyManager_CurrentItemChanged(object sender, System.EventArgs e)
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnCurrentChanged(System.EventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordState(int
newPosition, bool validating, bool endCurrentEdit, bool firePositionChange =
true, bool pullData)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.List_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.OnListChanged(System.ComponentModel.ListChangedEventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.SetList(System.Collections.IList list, bool metaDataChanged, bool applySortAndFilter = false)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.ParentCurrencyManager_CurrentItemChanged(object sender, System.EventArgs e)
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnCurrentItemChanged(System.EventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.List_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.OnListChanged(System.ComponentModel.ListChangedEventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.InnerList_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
[Native to Managed Transition]
[Managed to Native Transition]
Data.dll!Data.EntityCollection.OnListChanged(System.ComponentModel.ListChangedEventArgs args = {System.ComponentModel.ListChangedEventArgs})
Data.dll!Data.EntityCollection.OnListChanged(System.ComponentModel.ListChangedType eventType = ItemChanged, int newIndex = 0)
Data.dll!Data.EntityCollection.EntityModifiedEvent(object sender =
{Data1.Entity1}, System.EventArgs args = {System.EventArgs})
Data.dll!Data.Entity.OnEntityModified(System.EventArgs e =
{System.EventArgs})
Data.dll!Data.Entity.EndUpdateFromProxy()
Data1.dll!Data1.Entity1.Entity2Proxy_ListChanged(object sender =
{Data1.Entity2Collection}, System.ComponentModel.ListChangedEventArgs e =
{System.ComponentModel.ListChangedEventArgs})
Data.dll!Data.EntityCollection.OnListChanged(System.ComponentModel.ListChangedEventArgs args = {System.ComponentModel.ListChangedEventArgs})
Data.dll!Data.EntityCollection.Entity_PropertyChanged(object sender =
{Data1.Entity2}, System.ComponentModel.PropertyChangedEventArgs e =
{System.ComponentModel.PropertyChangedEventArgs})
Data.dll!Data.Entity.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e = {System.ComponentModel.PropertyChangedEventArgs})
Data.dll!Data.Entity.RaisePropertyChanged(string propertyName = "Entity3")
Data1.dll!Data1.Entity2.Entity3_PropertyChanged(object sender =
{Data1.Entity3}, System.ComponentModel.PropertyChangedEventArgs e =
{System.ComponentModel.PropertyChangedEventArgs})
[Native to Managed Transition]
[Managed to Native Transition]
Data.dll!Data.Entity.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e = {System.ComponentModel.PropertyChangedEventArgs})
Data.dll!Data.Entity.RaisePropertyChanged(string propertyName =
"SelectedValueProperty")
Data1.dll!Data1.Entity3.SetValue(string propertyName = "Property1", int
value = 2, System.Collections.Generic.List<Lookups.Lookup> lookups = Count =
4)
Data1.dll!Data1.Entity3.Property1Key.set(int value = 2)
I've not included a description of the relationships of the various objects
and their associated bindings, but will do so if that is needed.
Do you recognize this problem and know a solution?
Thank you!
Mike
I've tried ListBox, ComboBox, and as shown below a custom derived control (in
fact the RadioButtonList control described in a July 2004 MSDN article). Here
is a sequence of happenings that is giving me grief:
1) I select an item that is not the first item in the ListControl and which
is not the currently selected item
2) I tab out of the ListControl
3) The property to which the ListControl's SelectedValue is bound is updated
4) The bound object raises a PropertyChanged event, initating a sequence of
ListChanged events
5) Ultimately, the ListControl.SelectedIndex property is set to 0 and the
top item in the ListControl shows as the selected item
If I change a property on another control on the TabPage then the
ListControl changes to show the correct selected item (the one selected in
step 1 above). Thereafter, the ListControl will show the correct selected
item as it is changed.
Here's a stack trace at the moment the SelectedIndex is being set to 0. The
line at the bottom of the stack trace shows the property bound to the
SelectedValue property of the ListControl being set to 2 which corresponds to
a SelectedIndex value of 1. The top line in the trace shows the SelectedIndex
value being incorrectly set to 0.
UI.dll!UI.ListControl.SelectedIndex.set(int value = 0)
System.Windows.Forms.dll!System.Windows.Forms.ListControl.DataManager_PositionChanged(object sender, System.EventArgs e)
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnPositionChanged(System.EventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordState(int
newPosition, bool validating, bool endCurrentEdit, bool firePositionChange,
bool pullData)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.Position.set(int value)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.ParentCurrencyManager_CurrentItemChanged(object sender, System.EventArgs e)
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnCurrentChanged(System.EventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordState(int
newPosition, bool validating, bool endCurrentEdit, bool firePositionChange =
true, bool pullData)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.List_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.OnListChanged(System.ComponentModel.ListChangedEventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.SetList(System.Collections.IList list, bool metaDataChanged, bool applySortAndFilter = false)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.ParentCurrencyManager_CurrentItemChanged(object sender, System.EventArgs e)
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.OnCurrentItemChanged(System.EventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.List_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.OnListChanged(System.ComponentModel.ListChangedEventArgs e)
System.Windows.Forms.dll!System.Windows.Forms.BindingSource.InnerList_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
[Native to Managed Transition]
[Managed to Native Transition]
Data.dll!Data.EntityCollection.OnListChanged(System.ComponentModel.ListChangedEventArgs args = {System.ComponentModel.ListChangedEventArgs})
Data.dll!Data.EntityCollection.OnListChanged(System.ComponentModel.ListChangedType eventType = ItemChanged, int newIndex = 0)
Data.dll!Data.EntityCollection.EntityModifiedEvent(object sender =
{Data1.Entity1}, System.EventArgs args = {System.EventArgs})
Data.dll!Data.Entity.OnEntityModified(System.EventArgs e =
{System.EventArgs})
Data.dll!Data.Entity.EndUpdateFromProxy()
Data1.dll!Data1.Entity1.Entity2Proxy_ListChanged(object sender =
{Data1.Entity2Collection}, System.ComponentModel.ListChangedEventArgs e =
{System.ComponentModel.ListChangedEventArgs})
Data.dll!Data.EntityCollection.OnListChanged(System.ComponentModel.ListChangedEventArgs args = {System.ComponentModel.ListChangedEventArgs})
Data.dll!Data.EntityCollection.Entity_PropertyChanged(object sender =
{Data1.Entity2}, System.ComponentModel.PropertyChangedEventArgs e =
{System.ComponentModel.PropertyChangedEventArgs})
Data.dll!Data.Entity.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e = {System.ComponentModel.PropertyChangedEventArgs})
Data.dll!Data.Entity.RaisePropertyChanged(string propertyName = "Entity3")
Data1.dll!Data1.Entity2.Entity3_PropertyChanged(object sender =
{Data1.Entity3}, System.ComponentModel.PropertyChangedEventArgs e =
{System.ComponentModel.PropertyChangedEventArgs})
[Native to Managed Transition]
[Managed to Native Transition]
Data.dll!Data.Entity.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e = {System.ComponentModel.PropertyChangedEventArgs})
Data.dll!Data.Entity.RaisePropertyChanged(string propertyName =
"SelectedValueProperty")
Data1.dll!Data1.Entity3.SetValue(string propertyName = "Property1", int
value = 2, System.Collections.Generic.List<Lookups.Lookup> lookups = Count =
4)
Data1.dll!Data1.Entity3.Property1Key.set(int value = 2)
I've not included a description of the relationships of the various objects
and their associated bindings, but will do so if that is needed.
Do you recognize this problem and know a solution?
Thank you!
Mike