Attribute Table with zoom to and edit, save and query features

Apr 10, 2012 at 11:24 AM

Is there any code by which i can view attribute table of selected layer item from legend.on selected item i can zoom and run the query on attributes and edit and save the changes.

Developer
Apr 10, 2012 at 5:57 PM

Have you looked at DotSpatial.Plugins.TableEditor? it seems the code there is designed to let you "view attribute table of selected layer item from legend."

Apr 11, 2012 at 5:00 AM
Edited Apr 11, 2012 at 5:43 AM

Thanks mudnug.Please could you point me in right direction, link .I am new to DotSpatial

Developer
Apr 11, 2012 at 4:34 PM
Edited Apr 11, 2012 at 4:34 PM

In general, if you add the DotSpatial.Plugins.TableEditor.dll to your project Plugins folder you will be able to right-click a layer and open the Attribute Table Editor.

Apr 12, 2012 at 11:50 AM

Where do i can find this dll's...??? and this plugin folder should be present in solution folder...???Do i have to add any reference....????

Developer
Apr 12, 2012 at 4:39 PM

You'll find the dll in DotSpatial 1.1 Extended.zip You don't need to add a reference to it. It is discovered if it is in the Plugins folder.

Apr 16, 2012 at 7:50 AM
Edited Apr 16, 2012 at 8:38 AM

@ mudnug - I copied DotSpatial.Plugins.TableEditor.dll and other dll into bin\Debug\Plugins and bin\Debug\Application Extensions but it did not work. So i tried on menu item click event I wrote following code.

 DotSpatial.Plugins.TableEditor.TableEditorPlugin tb = new DotSpatial.Plugins.TableEditor.TableEditorPlugin();         

  tb.Activate();

it gave error could tell me how to use this plugin on button click.

Developer
Apr 17, 2012 at 7:03 PM

When an extension is loaded, we guarantee that it will be able to access an AppManager, IProgressHandler, and IHeaderControl. This allows the developer to avoid checking whether these properties are null before each use. This means, however, that extensions fulfilling these requirements must be available. In DemoMap.exe implementations are included in the project itself as classes. In MapWindow 6, example implementations are included as extensions. You can use whichever suits you.

 

I've written a tutorial to help you out: http://mudnug.wordpress.com/2012/04/17/composing-an-application-by-using-extensions/

Feb 4, 2013 at 5:12 AM
Dear all,

I am unable to use

DotSpatial.Plugins.TableEditor.TableEditorPlugin tb = new DotSpatial.Plugins.TableEditor.TableEditorPlugin();
tb.Activate();

It also throws error. How can I use TableEditorPlugin. Please show me the way
May 13, 2013 at 12:17 PM
i can't use the Table Editor Plugin too, please help
May 14, 2013 at 12:06 PM
This works for me in VB.NET with DS 1.4

Imports DotSpatial.Plugins.TableEditor
 Private Sub _buttonTable_ExecuteEvent(ByVal sender As Object, ByVal e As ExecuteEventArgs)
            Dim ActPolyLayer As MapPolygonLayer = Nothing
            Dim ActLineLayer As MapLineLayer = Nothing
            Dim ActPointLayer As MapPointLayer = Nothing

            
            Map1.FunctionMode = FunctionMode.None

            If Map1.Layers.Count > 0 Then
                For i = 0 To Map1.Layers.Count - 1
                    If Map1.Layers(i).IsSelected = True Then
                        If FeatureLayerType(Map1, i) = "PolyGon" Then
                            ActPolyLayer = CType(Map1.Layers(i), MapPolygonLayer)
                            ActPolyLayer.ShowAttributes()
                        End If
                        If FeatureLayerType(Map1, i) = "PolyLine" Then
                            ActLineLayer = CType(Map1.Layers(i), MapLineLayer)
                            ActLineLayer.ShowAttributes()
                        End If
                        If FeatureLayerType(Map1, i) = "Point" Then
                            ActPointLayer = CType(Map1.Layers(i), MapPointLayer)
                            ActPointLayer.ShowAttributes()
                        End If

                    End If
                Next
            End If
        End Sub
Jul 3, 2013 at 5:18 PM
This code is not working in C#, I have trouble converting FeatureLayerType? can some one help.

thanks
Jul 4, 2013 at 1:18 PM
the community would be helped by a step by step way of doing things from teh perspective of a moderate programmer..... most examples are to much relying on a time consuming research on how to get things working.....
Jul 5, 2013 at 8:06 PM
VB and C# are not my strong points. I mostly do C++. But anyway, I made a button in the form and added a button click event in c#.

using DotSpatial.Plugins.TableEditor;
 private void button10_Click(object sender, EventArgs e)
    {
        IMapLayer layerSelect = appManager1.Map.Layers.SelectedLayer;
        if (! isnothing (layerSelect))  <------------  can't find c# equivalent of isnothing 
        {
            try
            {
                IMapFeatureLayer layerFeature = ((IMapFeatureLayer)layerSelect);
                FormTableEditor fTableEditor = new FormTableEditor();  <----------------------------FormTableEditor is not defined
                fTableEditor.Text = "Attribute Table Editor - " + layerFeature.Name;  <------------------------Name is not a member of  layerFeature
                fTableEditor.tableEditorControl1.FeatureLayer = layerFeature;
                fTableEditor.Show();
            }
            catch (Exception ex)
            {
               MessageBox.Show  ("Error: " + ex.Message);
            }
        }
    }
  ================here are the compiler error list================
C:\Users\asus\Documents\Visual Studio 2010\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs(87,19): error CS0103: The name 'isnothing' does not exist in the current context
C:\Users\asus\Documents\Visual Studio 2010\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs(92,21): error CS0246: The type or namespace name 'FormTableEditor' could not be found (are you missing a using directive or an assembly reference?)
C:\Users\asus\Documents\Visual Studio 2010\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs(92,56): error CS0246: The type or namespace name 'FormTableEditor' could not be found (are you missing a using directive or an assembly reference?)
C:\Users\asus\Documents\Visual Studio 2010\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs(93,84): error CS1061: 'DotSpatial.Controls.IMapFeatureLayer' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'DotSpatial.Controls.IMapFeatureLayer' could be found (are you missing a using directive or an assembly reference?)
Jul 15, 2013 at 8:52 PM
The code generates an error for me at

If FeatureLayerType(myVenster, i) = "PolyGon" Then

and even so for lines andpoints....

FeatureLayerType is not declared, it may be unaccessible due to its own protectionlevel

anyone got an idea...?
    Private Sub ToolStripButtonTabelweergave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonTabelweergave.Click

        Dim ActPolyLayer As MapPolygonLayer = Nothing
        Dim ActLineLayer As MapLineLayer = Nothing
        Dim ActPointLayer As MapPointLayer = Nothing


        myVenster.FunctionMode = FunctionMode.None

        If myVenster.Layers.Count > 0 Then
            For i = 0 To myVenster.Layers.Count - 1
                If myVenster.Layers(i).IsSelected = True Then
                    If FeatureLayerType(myVenster, i) = "PolyGon" Then
                        ActPolyLayer = CType(myVenster.Layers(i), MapPolygonLayer)
                        ActPolyLayer.ShowAttributes()
                    End If
                    If FeatureLayerType(myVenster, i) = "PolyLine" Then
                        ActLineLayer = CType(myVenster.Layers(i), MapLineLayer)
                        ActLineLayer.ShowAttributes()
                    End If
                    If FeatureLayerType(myVenster, i) = "Point" Then
                        ActPointLayer = CType(myVenster.Layers(i), MapPointLayer)
                        ActPointLayer.ShowAttributes()
                    End If

                End If
            Next
        End If

    End Sub
Jul 15, 2013 at 9:24 PM
You need to add this function
 Public Function FeatureLayerType(ByVal dsMap As DotSpatial.Controls.Map, ByVal layerindex As Integer) As String

            If Not TryCast(dsMap.Layers(layerindex), MapPointLayer) Is Nothing Then

                FeatureLayerType = "Point" 'Point Layer

            ElseIf Not TryCast(dsMap.Layers(layerindex), MapLineLayer) Is Nothing Then

                FeatureLayerType = "PolyLine"

            ElseIf Not TryCast(dsMap.Layers(layerindex), MapPolygonLayer) Is Nothing Then

                FeatureLayerType = "PolyGon"

            Else

                FeatureLayerType = "NonFeatureLayer"

            End If

            Return FeatureLayerType

        End Function
Jul 15, 2013 at 9:52 PM
thx it worked!! that was the missing link


what i noticed is that i cant save any edit to shapefile Unable to save edits: the specified filetype is not supported

any idea why it isnt as this table editor could help solve many edit problems i have
Developer
Mar 25, 2014 at 1:56 AM
     public string FeatureLayerType( Map dsMap, int index)
     {
         string r = dsMap.Layers[index].ToString();
         return r;  
     }