Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: User-controls VB.NET
Hi Folks,
 
I am calling a user control(Say UC1) inside a panel(panel1)
then through UC1 i am again calling user control(Ssy UC2) for the same panel(panel1) by using this code in UC1:
 
Private Sub Button_Enter_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Enter.Click
        Panel1.Controls.Clear()
        'Panel1.BackgroundImage = My.Resources.module_2bg
        Dim obj1 As TherapyUC = New TherapyUC()
 
        Panel1.Controls.Add(obj1)
        obj1.Dock = DockStyle.Fill
        obj1 = Nothing
End Sub
 
Doing this way, creates an Error at Panel1.Controls.Add(obj1)
 

 
System.ComponentModel.Win32Exception was unhandled
ErrorCode=-2147467259
Message=Error creating window handle.
NativeErrorCode=87
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at Avas.TherapyUC.Button_Enter_Click(Object sender, EventArgs e) in D:\AVAS\homebasic_27_Mar_2012\Elliptical\UserControls\TherapyUC.vb:line 86
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Avas.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
 

 
Is there any other way to do this or how can i solve this..?
 
Every reply will be appreciated..
Posted 7-May-13 0:31am
(unknown member)
Comments
Sergey Alexandrovich Kryukov at 7-May-13 14:44pm
   
Add a tag to this question: "WinForms".
—SA
Sergey Alexandrovich Kryukov at 7-May-13 14:45pm
   
In which line of your code does it throws?
—SA
Sergey Alexandrovich Kryukov at 7-May-13 14:46pm
   
There is no such concept as "call a control". What exactly are you trying to do?
 
Why: "obj1 = Nothing" ??!!!
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Afzaal Ahmad Zeeshan 82
4 Sergey Alexandrovich Kryukov 75
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 7 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100