Controls at runtime
Controls at runtime
Controls at runtime
Controls at runtime
Controls at runtime
Controls at runtime Controls at runtime Controls at runtime Controls at runtime Controls at runtime Controls at runtime Controls at runtime Controls at runtime
Controls at runtime Controls at runtime
Controls at runtime
Go Back  Xtreme Visual Basic Talk > > > Controls at runtime


Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2005, 11:11 AM
NekoManu's Avatar
NekoManu NekoManu is offline
Regular
 
Join Date: Jun 2004
Location: Belgium
Posts: 79
Default Controls at runtime


I load a form and on that form I put some controls at runtime. Everything works fine, until I load the form a second time. Then I get the error 360: Object already loaded.

What am I doing wrong?

Here is the code:
Code:
    For nObjectCounter = 0 To UBound(ffFindFields)
        nObjectTop = nObjectTop + 360
        If nObjectCounter > 0 Then
            Load frmFind.lblFind(nObjectCounter)
            Load frmFind.txtFind(nObjectCounter)
        End If
        With frmFind.lblFind(nObjectCounter)
            .Caption = ffFindFields(nObjectCounter).sFieldCaption
            .Top = nObjectTop
            .Visible = True
        End With
        With frmFind.txtFind(nObjectCounter)
            .TabIndex = nObjectCounter
            .Top = nObjectTop
            .Visible = True
        End With
    Next
Reply With Quote
  #2  
Old 06-06-2005, 11:19 AM
00100b's Avatar
00100bControls at runtime 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

When you unload a form, the form instance isn't necessarily destroyed (nor are the control instances that it contains).

If it isn't possible for you to set the form instance to Nothing between loads, then unload the controls that you added from within the form's unload event.
__________________
The only stupid question is the one that goes un-asked.
Reply With Quote
  #3  
Old 06-06-2005, 11:29 AM
NekoManu's Avatar
NekoManu NekoManu is offline
Regular
 
Join Date: Jun 2004
Location: Belgium
Posts: 79
Default

How do I set the instance of the form to Nothing?

I load the form with: Load frmFind
Reply With Quote
  #4  
Old 06-06-2005, 11:36 AM
NekoManu's Avatar
NekoManu NekoManu is offline
Regular
 
Join Date: Jun 2004
Location: Belgium
Posts: 79
Default

Thank you. it works
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Controls at runtime
Controls at runtime
Controls at runtime Controls at runtime
Controls at runtime
Controls at runtime
Controls at runtime Controls at runtime Controls at runtime Controls at runtime Controls at runtime Controls at runtime Controls at runtime
Controls at runtime
Controls at runtime
 
Controls at runtime
Controls at runtime
 
-->