472,784 Members | 700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

(VB.NET) Accessing ActiveX controls created at runtime

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.Items("name").RemoteHost 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.RemoteHost = "127.0.0.1"), but then I get an error at runtime: Exception of type System.Windows.Forms.AxHost+InvalidActiveXStateExc eption' 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 1397

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

Similar topics

2
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...
3
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...
7
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...
11
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...
0
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...
0
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...
7
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...
3
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...
4
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...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.