borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (ActiveX Control Upgrade Utility)Next Topic (Is it possible to customize and ActiveX component?) New Topic New Poll Post Reply
AndreaVB Forum : ActiveX : Creating Control At RunTime as well as set the properties or events of those controls
Poster Message
debughosh
Level: Guest


icon Creating Control At RunTime as well as set the properties or events of those controls

Sir,
I am Debasis Ghosh From Kolkata (India) wants your suggestion or help. I would be grateful if you kindly provide some tips on following problem.

I want to create some control during runtime or at runtime. I know how to create the Control during runtime; you can see this from my project (Project Name: - Creating Controls At Runtime.vbp). But problem lays HOW TO SET THE PROPERTIES OR EVENTS OF THOSE CONTROLS. I’m unable to solve the problem with SUBCLASSING.

Again I want to create some User Control During Runtime as well as how would I set the properties of  those UserControls. If you want to see the code. You can send me mail.

Please help me. Mail me at debughosh@vsnl.net


Thanking you
Debasis Ghosh
  

24-07-2003 at 09:41 AM
| Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Re: Creating Control At RunTime as well as set the properties or events of those controls

well, one way that i can show you on how to create controls during runtime is by using an array of the controls you want to use...

i searched the net for this code, and i guess it can help you, if you are willing to go this way...

'**************************************
' Name: Create New Controls At Runtime
'    
' Description:This code will allow you to create a new instance
'of a control at runtime !
' By: Marc A. Foumberg
'
'
' Inputs:None
'
' Returns:None
'
'Assumes:NONE
'
'Side Effects:NONE
'This code is copyrighted and has limite
'     d warranties.
'Please see http://www.Planet-Source-Cod
'     e.com/xq/ASP/txtCodeId.1357/lngWId.1/qx/
'     vb/scripts/ShowCode.htm
'for details.
'**************************************

'Create a new project.
'Add a command button.
'Name the button...
' Command1(0)
'As if it were an aray.
'Its sometimes easyier to create
'an aray to begin with. If you do
'be sure to delete all button except
'Command1(0).
'The Code...


Private Sub Command1_Click(Index As Integer)
    Static I As Integer
    I = I + 1
    Load Command1(I)
    Command1(I).Left = Command1(I - 1).Left + 200
    Command1(I).Top = Command1(I - 1).Top + 600
    Command1(I).Caption = "New Button !"
    Command1(I).Visible = True
End Sub
'At runtime this will create a new
'command button.
'To add additional function you could ad
'     d
'an IF statement. As follows...


Private Sub Command1_Click(Index As Integer)
    On Error GoTo Handler1
    'Create new button
    Static I As Integer
    I = I + 1
    Load Command(I)
    Command(I).Left = 2460
    Command(I).Top = 5520
    Command(I).Caption = "For Real This Time" ' change the caption
    Command(I).Visible = True
    ' Code to unload the form when the new b
    '     utton is clicked


    If Command(1) Then
        Unload Me
    End If
    Handler1:
End Sub
'Email Marc at 3dtech@acwn.com with any
'     questions.
'try this with other controls !


that good enough?  

____________________________
Been busy trying to take a second degree <--it's not working out...

28-07-2003 at 04:07 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : ActiveX : Creating Control At RunTime as well as set the properties or events of those controls
Previous Topic (ActiveX Control Upgrade Utility)Next Topic (Is it possible to customize and ActiveX component?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder