473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 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 1421

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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.