I had posted code earlier regarding how to create a check box array (like in older VB).
The topic is here: http://www.dreaminco...wtopic33191.htm
Basic idea is this:
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.
The original idea to use SIMPLE Check Boxes did not work, although I got very close.
I have found that using the alternative "CheckedListBox" works just as well:
This code loads the checkedlistbox and sets all boxes to checked when the form loads:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim NumLayers As Integer NumLayers = AxMapControl1.LayerCount MsgBox(NumLayers) Dim i As Integer For i = 0 To NumLayers - 1 CheckedListBox1.Items.Add(AxMapControl1.Map.Layer(i).Name, True) Next i End Sub
This code SHOULD check to see what the checked state is and if it's CHECKED, then UNCHECK it, otherwise, CHECK IT
Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged If CheckedListBox1.SelectedIndex() = checked Then 'uncheck it CheckedListBox1.SelectedIndex(0) = unchecked Else 'must already be unchecked, so check it CheckedListBox1.SelectedIndex() = checked End If End Sub
Now I know THIS is not working, but I am not sure exactly how to implement what I want.
I did find (don't remember where, the CHECKSTATE method, but was not able to implement it to any satisfaction.
Any ideas (I'll thank Psychocoder in advance...)
Nolan

Reply





MultiQuote




|