1 Replies - 184 Views - Last Post: 02 February 2018 - 12:17 PM Rate Topic: -----

#1 xsancho   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-February 18

Delete tabpage in instance form from another form

Posted 02 February 2018 - 10:52 AM

I will try to explain :

I have this code to create a new form :

    Sub AbrirFichaCLiente(id As Integer)

        Dim MyfrmCliente As frmClienteyMascota
        MyfrmCliente = New frmClienteyMascota

        MyfrmCliente.IdCliente = id

        MyfrmCliente.MdiParent = MDI
        MyfrmCliente = Nothing

This form have a tabcontrol and if i click on a button it creates a tabpage

            Dim MiTab As TabPage = CreaTabPage()
            IncrustaFormAnimal(-1, MiTab)

No problem to create a tabpage!

    Function CreaTabPage() As TabPage

        Dim myTabPage = New TabPage
        myTabPage = New TabPage()

        myTabPage.Text = "Animal" & (TabAnimales.TabPages.Count + 1)
        Return myTabPage

    End Function

When I have created the tabpage i put into each tab a form :

    Sub IncrustaFormAnimal(myid As Integer, _MiTabPage As TabPage)

        Dim MyFrmAnimal As frmAnimal
        MyFrmAnimal = New frmAnimal

        With MyFrmAnimal

            .TopMost = False
            .TopLevel = False
            .Parent = _MiTabPage
            .Dock = DockStyle.Fill
            .BackColor = Color.White
            .Idcli = IdCliente
            .Dock = DockStyle.Fill
            .Idanimal = myid

            If myid <> -1 Then
                .txtNombre.Text = MyAnimalName
            End If


        End With

        'TabAnimales.SelectedTab = _MiTabPage
        '_MiTabPage.Text = MyAnimalName

        MyFrmAnimal = Nothing

    End Sub

In this form i have a button (Button3_Click) to delete a tab from form created, but I don't know how to pass a reference for this form cause it's says:

System.NullReferenceException: 'Referencia a objeto no establecida como instancia de un objeto.'

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

  End Sub

I can close the form but can't close tabpage because the tabpage is not in the form


Is This A Good Question/Topic? 0
  • +

Replies To: Delete tabpage in instance form from another form

#2 modi123_1   User is online

  • Suitor #2
  • member icon

Reputation: 14045
  • View blog
  • Posts: 56,207
  • Joined: 12-June 08

Re: Delete tabpage in instance form from another form

Posted 02 February 2018 - 12:17 PM

Perhaps declare your form variables as globals so they persist outside of the event scope.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1