Treeview Fehlermeldung

  • VB.NET

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von picoflop.

    Treeview Fehlermeldung

    Hallo zusammen, ich versuche im moment mit TreeView zu arbeiten jetzt kommt bei folgendem Quelltext eine fehlermeldung, was bedeutet diese?

    VB.NET-Quellcode

    1. Public Class Form1
    2. Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles Button1.Click
    3. If TreeView1.Nodes(0).Checked = True Then
    4. MsgBox("Hallo")
    5. End If
    6. End Sub
    7. End Class




    System.InvalidCastException wurde nicht behandelt.
    Message="Das Objekt des Typs "System.Windows.Forms.MouseEventArgs" kann nicht in Typ "System.Windows.Forms.TreeViewEventArgs" umgewandelt werden."
    Source="WindowsApplication3"
    StackTrace:
    bei WindowsApplication1.Form1._Lambda$__1(Object a0, EventArgs a1) in C:\Dokumente und Einstellungen\nelles\Desktop\Eingabe\WindowsApplication3\WindowsApplication3\Form1.Designer.vb:Zeile 0.
    bei System.Windows.Forms.Control.OnClick(EventArgs e)
    bei System.Windows.Forms.Button.OnClick(EventArgs e)
    bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    bei System.Windows.Forms.Control.WndProc(Message& m)
    bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
    bei System.Windows.Forms.Button.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.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(ApplicationContext context)
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    bei WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.
    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()
    InnerException:



    VIELEN DANK

    peeen schrieb:

    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles Button1.Click

    Das "handles button1.click" ist irgendwie Mumpitz. Der Handler hat die Signatur von TreeView.AfterSelect, soll aber das Event Button.Click bearbeiten? Hast du das "händisch" umgeschrieben?
    Mach aus Button1.Click mal TreeView1.AfterSelect. Dann sollte es gehen.