This project is read-only.

Field used for symbology, how to prevent to delete this column?

Oct 29, 2012 at 1:41 PM

Hi,

If I use a field to make any symbology shading and open after this the Atribute Table Editor, I can remove this field as any other.

This makes my app do not open the symbology property dialog anymore. The same happens with MapWindow 6.


 Featureset.cs at this line

counts[i] = DataTable.Select(expressions[i]).Length; 

Message=Cannot find column [V01]

Is there any way to check out if a column is used for symbology and disable deleting?

 

Feb 3, 2015 at 11:17 PM
Hi,

I found a "dirty" solution for this Problem but I want to do it better.
What I Need is the Name of the field used for the symbology of the selected layer

This is my workarround to only show the not used fileds to remove

If _featureLayer.Symbology.LegendText <> dc.ToString Then
                       field.Add(dc.ToString)
End If



Here my Code:
        Private Sub _ButtonDeleteColumn_ExecuteEvent(ByVal sender As Object, ByVal e As ExecuteEventArgs)

            If Map1.Layers.Count > 0 Then
                For i = 0 To Map1.Layers.Count - 1
                    If Map1.Layers(i).LegendText = XpTabControl1.SelectedTab.Text Then

                        If FeatureLayerType(Map1, i) = "NonFeatureLayer" Then
                            Exit Sub
                            'MessageBox.Show("The layer is not a valid layer.")
                        Else

                            Select Case FeatureLayerType(Map1, i)
                                Case "PolyGon"
                                    _featureLayer = CType(Map1.Layers(i), MapPolygonLayer)
                                Case "PolyLine"
                                    _featureLayer = CType(Map1.Layers(i), MapLineLayer)
                                Case "Point"
                                    _featureLayer = CType(Map1.Layers(i), MapPointLayer)
                            End Select


                            If _featureLayer.DataSet.AttributesPopulated Then
                                Dim field As List(Of String) = New List(Of String)
                                Dim selectedField As List(Of String) = New List(Of String)
                               
                                For Each dc As DataColumn In _featureLayer.DataSet.DataTable.Columns

                                    If _featureLayer.Symbology.LegendText <> dc.ToString Then
                                        field.Add(dc.ToString)
                                    End If

                                Next
                                Dim del As DeleteFieldsDialog = New DeleteFieldsDialog(field)
                                If (del.ShowDialog = DialogResult.OK) Then
                                    If (MessageBox.Show(Msg.DeleteColumn_Confirm, Msg.App_Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes) Then
                                        selectedField = del.SelectedFieldIdList
                                    End If
                                End If
                                
                                For Each fi As String In selectedField
                                    _featureLayer.DataSet.DataTable.Columns.Remove(fi)
                                Next

                               Else
                                MessageBox.Show("Column edits are not yet supported for datasets with more than 50, 000 attributes", Msg.App_Name)
                            End If

                        End If
                    End If

                Next
            End If

        End Sub
Feb 4, 2015 at 8:44 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.