I have an ActiveX control project, which contains a .frm and a .ctl. I need to reference one of the elements on the control from the form. Anyone know how to do this? It doesn't seem that the following works:
controlname!element.property
So I am wondering if there is a different syntax needed in this scenario.
I think memnoch is on point with what I'm looking for. TPR's thought would be good, but I'm dealing with an ActiveX control, not an ActiveX .dll or .exe, so I don't have the ability to reference objects of a class, since it is a .ctl, not a .cls. Thanks anyway, I'll let you all know how it turns out.
I can't seem to crack this one. The help that you offered, Memnoch, applies to property pages of a control. What I am specifically dealing with, is I have a .ctl and a .frm in the same project.
All that is on the form is a list box, which is populated by the user. Upon clicking enter, I want the contents of the listbox to populate a control in the .ctl I can not seem to gain a reference to the control at runtime though...hence, my dilemma.
Take a look at this sample project. All you should have to do to access a .ctl is to add it to the project just like you would a form or class or module. The only caviot being that the usercontrol has to be on the form drawn on the form to use it. I'm not sure you can initialize it any other way. But hopfully the sample project will help. Its very simple. Type in the top box and hit the button to transfer the text to the usercontrol textbox. As I said, very simple but hopefully what you are looking for?
The problem, is that this is going to be packaged into a .cab file for download to PCs across my company. So, my UserControl is going to be referenced directly on the web page, I can't reference a form that I have put the user control on (at least I am unaware of this capability if it does indeed exist.)
Well, it would have been easier if you would have said what you are doing with it. The answer is no.
While Microsoft doesn't have a sparkling security record, allowing type of referencing would be irresponsible. To my knowledge, a usercontrol running within IE is bound within this application. While it can access system resources and the like, it cannot be accessed through the browser itself. Only other html elements on your page can access the usercontrol.
I don't want to access these properties through the HTML, I want to reference the controls which are on the .ctl (the user control) from the .frm; all are in the same VB Project.
I don't think I understand what is the difference then between what you want to do and the example I posted. If you mean you want to do something like:
usercontrol.textbox1.text = "Put text here"
You can't. The usercontrol doesn't publically expose the controls to form that is hosting it. Rather, the programmer must expose the controls themselves. Like in the example, I created a set text and Get Text function. If you had multiple controls, You could place the controls in a control array and enumerate the controls for a hwnd that is set and got as a property.
You're on the right track with what I am wanting to do here is a link to the page that memnoch suggested earlier. It would do what I want, but my problem is that I need a reference to the particular user control in use and I can't figure out how to get it.
But, it seems that by using the "friend" function I can expose the controls for run-time manipulation from the form; again, I just need to get the specific reference.