Answered by:
Index was out of range. Must be non-negative and less than the size of the collection

Question
-
I got this error when I tried to get the entity. The error happened on the last statement.
ConfigFTPEntity ConfigFTPRow = new ConfigFTPEntity(); EntityCollection<ConfigFTPEntity> ConfigFTPCollection = new EntityCollection<ConfigFTPEntity>(new ConfigFTPEntityFactory()); private CurrencyManager _ConfigFTPManager; _ConfigFTPManager = (CurrencyManager)this.BindingContext[this.ultraComboX1.DataSource]; ConfigFTPRow = (ConfigFTPEntity)ConfigFTPCollection[_ConfigFTPManager.Position];
Wednesday, September 26, 2012 7:52 PM
Answers
-
In my opinion there's something wrong during binding the datasource...
mmm try this
(CurrencyManager)this.BindingContext[this.ultraComboX1.DataSource].Current;
or check the example in documentation page.
http://msdn.microsoft.com/en-us/library/system.windows.forms.currencymanager.aspx
- Proposed as answer by Jason Dot Wang Friday, September 28, 2012 5:42 AM
- Marked as answer by sdnd2000 Friday, September 28, 2012 9:22 PM
Wednesday, September 26, 2012 9:48 PM
All replies
-
try this statement and check if element get from position index will be correct
ConfigFTPRow = (ConfigFTPEntity)ConfigFTPCollection[_ConfigFTPManager.Position - 1];
Wednesday, September 26, 2012 7:59 PM -
See if it works
ConfigFTPEntity ConfigFTPRow = new ConfigFTPEntity(); EntityCollection<ConfigFTPEntity> ConfigFTPCollection = new EntityCollection<ConfigFTPEntity>(new ConfigFTPEntityFactory()); private CurrencyManager _ConfigFTPManager; _ConfigFTPManager = (CurrencyManager)this.BindingContext[this.ultraComboX1.DataSource]; ConfigFTPRow = (ConfigFTPEntity)ConfigFTPCollection[_ConfigFTPManager.Position -1];
Web Developer
Wednesday, September 26, 2012 8:01 PM -
just tried, it is the same. The ConfigFTPCollection is empty, that is the problem I think
- Edited by sdnd2000 Wednesday, September 26, 2012 8:50 PM
Wednesday, September 26, 2012 8:48 PM -
are you sure that 'this.ultraComboX1.DataSource' has been bound before?Wednesday, September 26, 2012 9:12 PM
-
I believe it is good
Wednesday, September 26, 2012 9:22 PM -
In my opinion there's something wrong during binding the datasource...
mmm try this
(CurrencyManager)this.BindingContext[this.ultraComboX1.DataSource].Current;
or check the example in documentation page.
http://msdn.microsoft.com/en-us/library/system.windows.forms.currencymanager.aspx
- Proposed as answer by Jason Dot Wang Friday, September 28, 2012 5:42 AM
- Marked as answer by sdnd2000 Friday, September 28, 2012 9:22 PM
Wednesday, September 26, 2012 9:48 PM