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
- Dim i As Integer
- i = 0
- For Each clsCamera In colCameras
- Dim cntDVTSID As New AxAxSID.AxDVTSID
- cntDVTSID.Visible = True
- cntDVTSID.Top = 29 * i
- cntDVTSID.Left = 149 * i
- cntDVTSID.Name = clsCamera.Name
- i += 1
- colCameraControls.Add(cntDVTSID, cntDVTSID.Name)
- lstCameras.Items.Add(clsCamera.Name)
- Next
- 'Add the controls to the form
- For Each cntDVTSID As AxAxSID.AxDVTSID In colCameraControls
- Me.Controls.Add(cntDVTSID)
- Next
edit: fixed code