Global Navigation Bar

MapInfo Products Knowledge Base


Product: MapXtreme 2004/2005
Version: 6.0, 6.1, 6.2, 6.5
Platform: Not Platform Related
Category: Desktop Controls

Summary:
How to create a custom Layer Control for a Desktop application

Question:
How to create a custom Layer Control for a Desktop application

Answer:

1. Select the MapToolBar on your form and view its properties.

2. Select the Collection button under the Buttons:




3. Add a new ToolBarButton to the MapToolBar:




4. Select the Tag for the Tool and the Style should be set to PushButton:




5. Declare a class level variable called layerControl:

C# Code:
private MapInfo.Windows.Dialogs.LayerControlDlg layerControl;

VB.Net Code:
Private layerControl As MapInfo.Windows.Dialogs.LayerControlDlg


6. In your MapForm1 function, add the following code to declare your LayerControl. This example removes the AddButton from the LayerControl.

C# Code:
layerControl = new MapInfo.Windows.Dialogs.LayerControlDlg();
layerControl.LayerControl.AddButton.Enabled = false;
layerControl.LayerControl.AddButton.Visible = false;
layerControl.Map = this.mapControl1.Map;

VB.Net Code:
layerControl = New MapInfo.Windows.Dialogs.LayerControlDlg
layerControl.LayerControl.AddButton.Enabled = False
layerControl.LayerControl.AddButton.Visible = False
layerControl.Map = Me.MapControl1.Map


7. In the ButtonClick event handler for the MapToolBar, add the following code:
    C# Code:
if(e.Button.Tag == "CustomLayerControl")
//e.Button.Tag needs to match the tag you set in the properties window
layerControl.ShowDialog();

    VB.Net Code:
If e.Button.Tag = "CustomLayerControl" Then
'e.Button.Tag needs to match the tag you set in the properties window
layerControl.ShowDialog()
End If


Last Modified: 04/13/2006 02:25:01 PM
Global Navigation Bar