ArgumentException

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NetRacer

    #1

    ArgumentException

    hi all,

    i have a form with a tabcontrol with 4 pages. on the first page are many
    controls bound to a database. now i bound the controls of page two (two
    multiline textboxes, four SelectedValues) to the db. the program compiles
    without an error and runs fine, until i click on tabpage 2. then the program
    throws the following exception:

    System.Argument Exception: Der Objekttyp kann nicht zum Zieltyp konvertiert
    werden. (english: Object type cannot be converted to target type)
    at System.Windows. Forms.Control.S etVisibleCore(B oolean value)
    at System.Windows. Forms.Control.s et_Visible(Bool ean value)
    at System.Windows. Forms.TabPage.s et_Visible(Bool ean value)
    at System.Windows. Forms.TabContro l.UpdateTabSele ction(Boolean uiselected)
    at System.Windows. Forms.TabContro l.OnSelectedInd exChanged(Event Args e)
    at System.Windows. Forms.TabContro l.WmSelChange(M essage& m)
    at System.Windows. Forms.TabContro l.WndProc(Messa ge& m)
    at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
    at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
    at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
    Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows. Forms.UnsafeNat iveMethods.Send Message(HandleR ef hWnd,
    Int32 msg, IntPtr wParam, IntPtr lParam)
    at System.Windows. Forms.Control.S endMessage(Int3 2 msg, IntPtr wparam,
    IntPtr lparam)
    at System.Windows. Forms.Control.R eflectMessageIn ternal(IntPtr hWnd,
    Message& m)
    at System.Windows. Forms.Control.W mNotify(Message & m)
    at System.Windows. Forms.Control.W ndProc(Message& m)
    at System.Windows. Forms.Scrollabl eControl.WndPro c(Message& m)
    at System.Windows. Forms.Container Control.WndProc (Message& m)
    at System.Windows. Forms.Form.WndP roc(Message& m)
    at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
    at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
    at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
    Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows. Forms.UnsafeNat iveMethods.Call WindowProc(IntP tr
    wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
    at System.Windows. Forms.Control.D efWndProc(Messa ge& m)
    at System.Windows. Forms.Control.W mMouseDown(Mess age& m, MouseButtons
    button, Int32 clicks)
    at System.Windows. Forms.Control.W ndProc(Message& m)
    at System.Windows. Forms.TabContro l.WndProc(Messa ge& m)
    at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
    at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
    at System.Windows. Forms.NativeWin dow.DebuggableC allback(IntPtr hWnd,
    Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows. Forms.UnsafeNat iveMethods.Disp atchMessageW(MS G& msg)
    at
    System.Windows. Forms.Component Manager.System. Windows.Forms.U nsafeNativeMeth ods+IMsoCompone ntManager.FPush MessageLoop(Int 32
    dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows. Forms.ThreadCon text.RunMessage LoopInner(Int32 reason,
    ApplicationCont ext context)
    at System.Windows. Forms.ThreadCon text.RunMessage Loop(Int32 reason,
    ApplicationCont ext context)
    at System.Windows. Forms.Applicati on.Run(Form mainForm)


    there is no line number of my code in the stacktrace, so i don't know where
    to look. can anyone help me?

    thx for any help
    netracer


  • Cor Ligthert

    #2
    Re: ArgumentExcepti on

    NetRacer,

    Your question has a standard answer that is long time not given.

    Put in the top of your program file.
    Option Strict On

    Probably you will than see the error.
    And feel than free to ask when you don't know how to solve that.
    (It needs than probably converting or casting)

    I hope this helps,

    Cor


    Comment

    • Armin Zingler

      #3
      Re: ArgumentExcepti on

      "Cor Ligthert" <notmyfirstname @planet.nl> schrieb[color=blue]
      > Your question has a standard answer that is long time not given.
      >
      > Put in the top of your program file.
      > Option Strict On[/color]


      In which file of the source files for System.Windows. Forms.dll?

      ;-)

      Armin

      Comment

      • NetRacer

        #4
        Re: ArgumentExcepti on

        i tried.
        after the correction (insert of CType(x,y)) of a lot of value assignments i
        recompiled my project and the effect is the same.
        i tried the option strict in every code file the code of this form goes
        through.

        the error message is still the same, without any hint, where to search
        for...



        "Cor Ligthert" <notmyfirstname @planet.nl> schrieb im Newsbeitrag
        news:uSe4HesWFH A.1152@TK2MSFTN GP09.phx.gbl...[color=blue]
        > NetRacer,
        >
        > Your question has a standard answer that is long time not given.
        >
        > Put in the top of your program file.
        > Option Strict On
        >
        > Probably you will than see the error.
        > And feel than free to ask when you don't know how to solve that.
        > (It needs than probably converting or casting)
        >
        > I hope this helps,
        >
        > Cor
        >[/color]


        Comment

        • Cor Ligthert

          #5
          Re: ArgumentExcepti on

          Netracer,

          Can you show us the code that does the tabpage2.

          Cor


          Comment

          • NetRacer

            #6
            Re: ArgumentExcepti on

            tabPage2 does nothing. there is no event handled.
            i bound the error to three controls on it now. if i comment out the
            DataBindings of these, it works.

            each of these controls is an inherited GroupBox with additional property
            "Value", nothing else changed. the Value is set by RadioButtons within the
            GroupBox and vice versa sets the RadioButtons.

            ----------
            the GroupBox Class:


            Public Class myGroupBox
            Inherits GroupBox

            Private m_value As Object
            Private m_setvalue As Boolean = False

            Public Event ValueChanged(By Val sender As Object, ByVal e As EventArgs)

            <Description("T he value of the selected RadioButton"), _
            Browsable(False ), Bindable(True)> _
            Public Property Value() As Object
            Get
            Return m_value
            End Get
            Set(ByVal Value As Object)
            m_value = Value
            RaiseEvent ValueChanged(Me , New EventArgs)
            End Set
            End Property

            Public Sub SetValue(ByVal val As Object)
            m_value = val
            End Sub

            End Class

            ---------
            in the Form:


            Private Sub grpFlag_KP_Valu eChanged(ByVal sender As System.Object, ByVal e
            As System.EventArg s) Handles grpFlag_KP.Valu eChanged
            Select Case grpFlag_KP.Valu e
            Case 2 : rdoFlag_Kostent eilung.Checked = True
            Case 1 : rdoFlag_kostenp flichtig.Checke d = True
            Case 0 : rdoFlag_kostenl os.Checked = True
            End Select
            End Sub


            Private Sub rdoFlag_Kostent eilung_CheckedC hanged(ByVal sender As
            System.Object, ByVal e As System.EventArg s) Handles
            rdoFlag_Kostent eilung.CheckedC hanged
            If CType(sender, RadioButton).Ch ecked Then grpFlag_KP.SetV alue(2)
            End Sub

            Private Sub rdoFlag_kostenp flichtig_Checke dChanged(ByVal sender As
            System.Object, ByVal e As System.EventArg s) Handles
            rdoFlag_kostenp flichtig.Checke dChanged
            If CType(sender, RadioButton).Ch ecked Then grpFlag_KP.SetV alue(1)
            End Sub

            Private Sub rdoFlag_kostenl os_CheckedChang ed(ByVal sender As System.Object,
            ByVal e As System.EventArg s) Handles rdoFlag_kostenl os.CheckedChang ed
            If CType(sender, RadioButton).Ch ecked Then grpFlag_KP.SetV alue(0)
            End Sub






            "Cor Ligthert" <notmyfirstname @planet.nl> schrieb im Newsbeitrag
            news:%23nWOLjuW FHA.1508@tk2msf tngp13.phx.gbl. ..[color=blue]
            > Netracer,
            >
            > Can you show us the code that does the tabpage2.
            >
            > Cor
            >[/color]


            Comment

            • Cor Ligthert

              #7
              Re: ArgumentExcepti on

              NetRacer,
              [color=blue]
              > tabPage2 does nothing. there is no event handled.
              > i bound the error to three controls on it now. if i comment out the
              > DataBindings of these, it works.
              >[/color]
              Than it is probably in that part, however in my opinion did you not show
              that.

              Cor


              Comment

              Working...