Exemplo n.º 1
0
        private void SetListDataSource()
        {
            if (_accountCollection != null)
            {
                Account        selectedAccount = lstAccounts.SelectedItem as Account;
                List <Account> accountList     = _accountCollection.ToAccountList().ToList();

                lstAccounts.BeginUpdate();
                int selectedIndex = -1;
                lstAccounts.Items.Clear();
                for (int i = 0; i < accountList.Count(); i++)
                {
                    Account act = accountList[i];
                    if (act.Equals(selectedAccount))
                    {
                        selectedIndex = i;
                    }
                    lstAccounts.Items.Add(act);
                }
                lstAccounts.SelectedIndex = selectedIndex;
                lstAccounts.EndUpdate();

                SetFormFromSelection();
            }
        }