5 Replies - 858 Views - Last Post: 07 March 2012 - 09:46 PM Rate Topic: -----

#1 christydivya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-March 12

error "Top-level control con't added to a control"when add

Posted 06 March 2012 - 10:07 PM

Public Class b

   
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Button2 As New Button
        Button2.Name = "Button2"
        Button2.Text = "box1"
        Button2.Top = 10
        Button2.Left = 10
        Me.Controls.Add(Button2)
    End Sub
End Class



while compiling it i got error like "top level controls can not be added to control"
what to do?

This post has been edited by AdamSpeight2008: 06 March 2012 - 10:48 PM
Reason for edit:: Please use the CODETAGS for encasing code


Is This A Good Question/Topic? 0
  • +

Replies To: error "Top-level control con't added to a control"when add

#2 shadachi  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 141
  • Joined: 25-January 08

Re: error "Top-level control con't added to a control"when add

Posted 06 March 2012 - 10:30 PM

How about setting .TopLevel = False?
Was This Post Helpful? 1
  • +
  • -

#3 christydivya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-March 12

Re: error "Top-level control con't added to a control"when add

Posted 07 March 2012 - 06:57 AM

View Postshadachi, on 06 March 2012 - 10:30 PM, said:

How about setting .TopLevel = False?

:bigsmile:
thank you so much for responding..
but i think it does not work or i may not know how to set the toplevel to false
i wonder if you help me out
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: error "Top-level control con't added to a control"when add

Posted 07 March 2012 - 07:19 AM

Are you by any chance trying to add a form into a panel on another form?
Was This Post Helpful? 0
  • +
  • -

#5 shadachi  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 141
  • Joined: 25-January 08

Re: error "Top-level control con't added to a control"when add

Posted 07 March 2012 - 04:37 PM

Are you using MDI ?

How bout referring to this TopLevel Setting link for the toplevel setting
Was This Post Helpful? 0
  • +
  • -

#6 christydivya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-March 12

Re: error "Top-level control con't added to a control"when add

Posted 07 March 2012 - 09:46 PM

View PostCharlieMay, on 07 March 2012 - 07:19 AM, said:

Are you by any chance trying to add a form into a panel on another form?

actually no :)
thanks anyway

View Postshadachi, on 07 March 2012 - 04:37 PM, said:

Are you using MDI ?

How bout referring to this TopLevel Setting link for the toplevel setting

:) thank you but that doesn't work
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1