Solved

loading controls

Posted on 2000-02-18
7
166 Views
Last Modified: 2013-11-13
I need to load a richtextbox during run time when a certain thing happens.

I use to do this with winsock on an array but I can't seem to do it the same way.   Any suggestions ?

So far i've got it loading a new one up setting it's position and making it visible but it's not working.
0
Comment
Question by:Dark_Angel
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 6

Expert Comment

by:Marine
ID: 2537396
What have you used to do this ? Have you tried using controls collection to do that ? Here is a sample code.
Dim withevents ctlCommand as VB.COmmandButton

Set ctlCommand = Controls.Add("VB.CommandButton", _
                    "ctlCommand1", Form1)
ctlcommand.move 0,0
ctlcommand.caption = "YAHOO"

Thats how the control is born in runtime. I suppose if you loading an ActiveX control it must be stil referenced i would think. I think the control then must be redestributed when you making a setup.
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2537915
I guess you are using a control array ?

I would normally have an instance of the control on a form, set its index to zero and make it invisible.

Then at run time do:

    Load myControl(NextControlIndex)
    With myControl(NextcontrolIndex)
        .Left = 100
        .Top = 100
        .Visible = True
    End With
    NextControlIndex = NextControlIndex+1

If thats what you're doing, in what way is it not working ?
0
 
LVL 3

Accepted Solution

by:
paulstamp earned 20 total points
ID: 2537918
Just tried the below code and it works... place a RTB on a form and a button. Then put the following code into the button and run. Everytime you press the button a new rich text box appears below and to the right of the last one :

Private Sub Command1_Click()

    Static nIndex As Integer
   
    nIndex = nIndex + 1
    Load RichTextBox1(nIndex)
    With RichTextBox1(nIndex)
        .Left = nIndex * .Width
        .Top = nIndex * .Height
        .Visible = True
    End With
   
End Sub
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:Marine
ID: 2538060
The problem with your code is guys that he doesn't want to create a control array in runtime he wants just a control in runtime wihtout having any control on the form at all where you just use load to create one. So the only way is to use VB Controls.ADD method to do so. Or there should be an API function similar to this.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2538128
VB6 supports .Add, Vb5 does not. If he's using VB5 then he must use an invisible "seed" control for the control array.

M
0
 

Author Comment

by:Dark_Angel
ID: 2539358
Thanks for the high interest..

I at first was going to load a richtextbox but I saw the array code and I think that will be easier since I'm not sure if i'll be needing more then one.

Thanks for all the info!
0
 

Author Comment

by:Dark_Angel
ID: 2539361
Thanks for the code
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now