Connecting Tech Pros Worldwide Forums | Help | Site Map

vb-Checkbox Array? Sample Code needed

Newbie
 
Join Date: Sep 2007
Posts: 1
#1: Sep 11 '07
Hi there.
I've read a previous thread regarding the Old VB 6 checkbox array and how it's not really needed any more.
That's fine, but I'm not really sure how to implement the checkbox control array in .NET.
I am using an ARCGIS map control which has "Layers" of spatial data (i.e. Roads, Creeks, Rivers, etc.)
When I load the form and the map control, I want to create a Dynamic Table of Contents in the form of Check Boxes in order to control whether the Layers will be visible or not.
Can someone please supply a sample snippet of code that will create an array of check boxes?

Here is my code, but I'm getting errors regarding "Use the 'NEW' keyword..."

CODE

'GET THE NUMBER OF LAYERS FROM THE MapControl
Dim NumLayers as Integer
NumLayers = AxMapControl1.LayerCount

'CREATE NEW CHECKBOX CONTROL ARRAY
Dim MyCheckboxes As New CheckBox()

'LOOP THROUGH THE LAYERS AND CREATE A CHECKBOX FOR EACH
Dim i As Integer
For i = 0 To NumLayers - 1
'if the number of layers is 5 our Layer array will be 0 to 4

'CYCLE THROUGH AND POPULATE CHECKBOXES

MyCheckboxes(i).Visible = True
MyCheckboxes(i).Checked = True
MyCheckboxes(i).Text = AxMapControl1.Map.Layer(i).Name

Next i
/CODE

I have done this in the past with VB 6 with no problems.
Can someone please supply a sample snippet of code that will create an array of check boxes?
Thanks.
Nolan

Reply