GartenUmgraben
Erfahrenes Mitglied
Moin..ich hab n ComboBox, die ich dynamisch mit Items fülle. Sobald Items vorhanden sind, sollen das DroppDown Menü sichtbar werden, wenn keine vorhanden sind, soll das DroppDown Menü entsprechend verschwinden.
Das geht soweit auch beim anzeigen des Menüs. Wenn ich jedoch nun die Itemsliste leere und den Befehl von oben ausführe, dann bekomme ich eine Exception
System.ArgumentOutOfRangeException wurde nicht behandelt.
Message="InvalidArgument=Value mit dem Wert 0 ist für index ungültig.\r\nParametername: index"
Source="System.Windows.Forms"
ParamName="index"
StackTrace:
bei System.Windows.Forms.ComboBox.ObjectCollection.get_Item(Int32 index)
bei System.Windows.Forms.ComboBox.get_Text()
bei System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
bei System.Windows.Forms.ComboBox.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
bei System.Windows.Forms.Control.WmCommand(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bei System.Windows.Forms.ContainerControl.WndProc(Message& m)
bei System.Windows.Forms.Form.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
bei System.Windows.Forms.Control.DefWndProc(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ComboBox.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam)
bei System.Windows.Forms.Control.SendMessage(Int32 msg, Int32 wparam, Int32 lparam)
bei System.Windows.Forms.ComboBox.set_DroppedDown(Boolean value)
bei SIS.Form1.comboBox_Ort_TextChanged(Object sender, EventArgs e) in D:\Projekte\SIS\SIS\SIS\Form1.cs:Zeile 45.
bei System.Windows.Forms.Control.OnTextChanged(EventArgs e)
bei System.Windows.Forms.ComboBox.OnTextChanged(EventArgs e)
bei System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
bei System.Windows.Forms.ComboBox.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
bei System.Windows.Forms.Control.WmCommand(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bei System.Windows.Forms.ContainerControl.WndProc(Message& m)
bei System.Windows.Forms.Form.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
bei System.Windows.Forms.Control.DefWndProc(Message& m)
bei System.Windows.Forms.Control.WmCommand(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ComboBox.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
bei System.Windows.Forms.ComboBox.DefChildWndProc(Message& m)
bei System.Windows.Forms.ComboBox.ChildWndProc(Message& m)
bei System.Windows.Forms.ComboBox.ComboBoxChildNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei SIS.Program.Main() in D:\Projekte\SIS\SIS\SIS\Program.cs:Zeile 17.
bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
Code:
this.comboBox1_Ort.DroppedDown = this.comboBox_Ort.Items.Count > 0;
Das geht soweit auch beim anzeigen des Menüs. Wenn ich jedoch nun die Itemsliste leere und den Befehl von oben ausführe, dann bekomme ich eine Exception
System.ArgumentOutOfRangeException wurde nicht behandelt.
Message="InvalidArgument=Value mit dem Wert 0 ist für index ungültig.\r\nParametername: index"
Source="System.Windows.Forms"
ParamName="index"
StackTrace:
bei System.Windows.Forms.ComboBox.ObjectCollection.get_Item(Int32 index)
bei System.Windows.Forms.ComboBox.get_Text()
bei System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
bei System.Windows.Forms.ComboBox.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
bei System.Windows.Forms.Control.WmCommand(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bei System.Windows.Forms.ContainerControl.WndProc(Message& m)
bei System.Windows.Forms.Form.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
bei System.Windows.Forms.Control.DefWndProc(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ComboBox.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam)
bei System.Windows.Forms.Control.SendMessage(Int32 msg, Int32 wparam, Int32 lparam)
bei System.Windows.Forms.ComboBox.set_DroppedDown(Boolean value)
bei SIS.Form1.comboBox_Ort_TextChanged(Object sender, EventArgs e) in D:\Projekte\SIS\SIS\SIS\Form1.cs:Zeile 45.
bei System.Windows.Forms.Control.OnTextChanged(EventArgs e)
bei System.Windows.Forms.ComboBox.OnTextChanged(EventArgs e)
bei System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
bei System.Windows.Forms.ComboBox.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
bei System.Windows.Forms.Control.WmCommand(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bei System.Windows.Forms.ContainerControl.WndProc(Message& m)
bei System.Windows.Forms.Form.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
bei System.Windows.Forms.Control.DefWndProc(Message& m)
bei System.Windows.Forms.Control.WmCommand(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ComboBox.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
bei System.Windows.Forms.ComboBox.DefChildWndProc(Message& m)
bei System.Windows.Forms.ComboBox.ChildWndProc(Message& m)
bei System.Windows.Forms.ComboBox.ComboBoxChildNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei SIS.Program.Main() in D:\Projekte\SIS\SIS\SIS\Program.cs:Zeile 17.
bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()