473,789 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(VB.NET) Accessing ActiveX controls created at runtime

1 New Member
I'm developing an app here that uses ActiveX controls to connect to industrial cameras over Ethernet. I want to be able to dynamically create those controls at runtime based on how many cameras are configured, rather than take the easy way out and put a fixed amount of controls on the form at design. Makes it more flexible.

At the moment the way I am trying to do it is adding instances of the control into a collection with their individual properties set, then for each-ing through the collection and adding the controls to the form. Now, this is where I get the problems. I can access the properties of the control, like height, name, and so on, but any of the properties or methods from the control itself are not accessible at all. I can't reference them by name (like "CameraControl. RemoteHost = "blah"); it causes a syntax error because the control isn't there yet. I can't do it through Me.Controls.Ite ms("name").Remo teHost because that property is not a property of the control class. I tried setting these properties before adding the item to the collection (by doing cntDVTSID.Remot eHost = "127.0.0.1" ), but then I get an error at runtime: Exception of type System.Windows. Forms.AxHost+In validActiveXSta teException' was thrown.

Here is the code I am using, if it helps:
Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. i = 0
  3.  
  4. For Each clsCamera In colCameras
  5.    Dim cntDVTSID As New AxAxSID.AxDVTSID
  6.    cntDVTSID.Visible = True
  7.    cntDVTSID.Top = 29 * i
  8.    cntDVTSID.Left = 149 * i
  9.    cntDVTSID.Name = clsCamera.Name
  10.    i += 1
  11.    colCameraControls.Add(cntDVTSID, cntDVTSID.Name)
  12.    lstCameras.Items.Add(clsCamera.Name)
  13. Next
  14.  
  15. 'Add the controls to the form
  16. For Each cntDVTSID As AxAxSID.AxDVTSID In colCameraControls
  17.    Me.Controls.Add(cntDVTSID)
  18. Next
  19.  
Anyone have some ideas? I'm really starting to miss control arrays from VB6 :)

edit: fixed code
Jul 2 '08 #1
0 1434

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7577
by: Fie Fie Niles | last post by:
This one XP machine (with IE 6) is having a problem viewing any ActiveX controls (created on VB6) on the Internet Explorer browser. I put the same ActiveX control in a VB program, and when I run the VB program on that same machine, I can view the ActiveX control fine. He is using Citrix. The same ActiveX controls can be viewed on other machines. When trying to view 1 of the ActiveX control, he got an error "Visual Basic Run-time redist...
3
2329
by: fumihiko | last post by:
Hi, I created an activex control (C++), and it uses another COM dll (C++). This COM dll links with a static library that dose some calculation. (both are debug multithreaded dll) I created a C# client having activex control embedded at the very beginning (added in the design window); then, I created another same activex control at the runtime. After the 2nd activex control is created, I start to get errors on the function calls to the...
7
7003
by: Lau Lei Cheong | last post by:
Hello, I'm using javascript's insertAdjacentHtml() to insert images to the webform at runtime. This runs fine(image successfully displayed at the browser) but when I tried to access the control's src using FindControl() function in the code-behind, it seems that the control doesn't even exist. I know that I can add controls on the server-side, but then a postback will be needed which is the thing I want to avoid. Does anyone have idea...
11
1755
by: Eric Dan | last post by:
Hi, This may sound a trivial question but I didn't find (yet) the equivalent of ..NET to ActiveX controls (good old COM way :-) ) or Java applets which I am not familiar with but I understand how they work. Just to explain more clearly. I am looking for: • An option to run a rich UI application on the client browser not based on HTML tags or formatting but pure .NET application that uses GDI+ and anything else required for an...
0
1046
by: Dan | last post by:
hI have a series of ActiveX controls written in VB6 that I want to now use in VB.NET. In the VB6 world I loaded these controls at runtime as needed. This worked great as they all implemented a common interface. I am having some issues now when I try to do the same things in VB.NET. The controls will load, however, they fail on the following line of code If TypeOf UserControl.Extender.Parent Is IControlInterface Then
0
1048
by: shawnn | last post by:
Hello, I need to license AxMSCommLib.AxMSComm at runtime, I'd rather not mess with the registry at install. I have seen this code posted all over the web: AxMSCommLib.AxMSComm com; string strLicense = "kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun";
7
4398
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do ActiveX controls that are to be used by a pda need to be written in the ..net compact framework, or am i missing something else here? i have a HP iPaq 2490 with Windows Mobile Premium installed While i'm at it; does a activex control allow you to...
3
2092
by: Toe Dipper | last post by:
In short we have a lengthy process when a form is loaded that adds activex controls to our windows form. This process in itself works fine however we would like to push this processing to a thread but are stumped so far. Our goal is simply to allow the form to fully display while the controls are being added. Preferrably with a progressbar to let them know that the form is still being built. Here are some snippets.
4
6790
by: Wilfried Mestdagh | last post by:
Hi, I have a C# application (VS2005) with Microsoft Mappoint activeX control on a form. At a certain moment I want to create a second one temporary in code. This seems not to work, when I try to access it I have an InvalidActiveXState Exception. I cannot find mutch on the web about this Invalid State of a component except that it is invalid (what the Exception already describe). So I hope someone here knows ?
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3703
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.