By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,506 Members | 1,876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,506 IT Pros & Developers. It's quick & easy.

vb-Checkbox Array? Sample Code needed

P: 1
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
Sep 11 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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