Link to home
Start Free TrialLog in
Avatar of Lucas López
Lucas López

asked on

Value '0' não é um valor válido para 'SelectedIndex'.

System.ArgumentOutOfRangeException was unhandled
  HResult=-2146233086
  Message=InvalidArgument=Value '0' não é um valor válido para 'SelectedIndex'.
Nome do parâmetro: SelectedIndex
  Source=System.Windows.Forms
  ParamName=SelectedIndex
  StackTrace:
       em System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
       em RemoteConsole.MainForm.AddMailTypeList(List`1 typeList) na D:\zhyz\Server Source\RemoteConsole\RemoteConsole\MainForm.cs:linha 124
       em RemoteConsole.Program.Main() na D:\zhyz\Server Source\RemoteConsole\RemoteConsole\Program.cs:linha 74
       em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       em System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       em System.Threading.ThreadHelper.ThreadStart()
  InnerException:


Code:        public void AddMailTypeList(List<MailTypeCfg> typeList)
        {
            foreach (MailTypeCfg ty in typeList)
            {
                comboBox2.Items.Add(ty.desc);
            }
            comboBox2.BeginUpdate();
            comboBox2.SelectedIndex = 0;
            comboBox2.EndUpdate();
        }

Help Pls!
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
All solutions show ways to handle the problem.