Use set_ShapeFillColor new version

Hi
Please can help me with this
I’m not an English speaker, sorry for my redaction
I try to fill diferentes polygon, but only fill one by one, i want to make same this code
I try with this code but only fill one

This code from “Getting Started With the MapWinGIS ActiveX Control”

   'Set up a coloring scheme for the countries polygons`
   Dim ShapeNum As Integer`
   Dim Region As String`

im FieldNum As Integer
FieldNum = 2
For ShapeNum = 0 To sfWorld.NumShapes - 1
Region = sfWorld.CellValue(FieldNum, ShapeNum)
Select Case Region
Case “Antarctica”
mapMain.set_ShapeFillColor(hndWorld, ShapeNum,
… Convert.ToUInt32(RGB(100, 50, 0)))![map|690x470]
Case “Asia”
mapMain.set_ShapeFillColor(hndWorld, ShapeNum,
… Convert.ToUInt32(RGB(120, 70, 20)))

i try with this

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim myWorldShape As New Mapwingis.Shapefile
    Dim Nestado As Integer = 0
    Nestado = CInt(TextBox1.Text)
    sfWorld = AxMap1.get_Shapefile(hndWorld)
    myWorldShape = AxMap1.get_GetObject(hndWorld)
    For i As Integer = 0 To myWorldShape.NumShapes
        If myWorldShape.CellValue(0, i) = Nestado Then
            MsgBox(myWorldShape.CellValue(1, i).ToString, MsgBoxStyle.OkOnly, "Estado")
            'pintar
            pintar(i + 1)
        End If
    Next
End Sub

Public Sub pintar(cve_ent As Integer)
    'Creado por: Daniel RM Fecha: 17/05/19 pinta los poligonos en la posicicon recibida
    AxMap1.Projection = tkMapProjection.PROJECTION_NONE
    AxMap1.GrabProjectionFromData = True
    Dim cad As String
    cad = String.Format("{0:00}", cve_ent) 'Agregamos formato igual al de la tabla de id
    Dim ct As New Mapwingis.ShapefileCategory
    ct = sfWorld.Categories.Add("Estados") ' Agregamos una categoria
    ct.Expression = "[CVE_ENT] = """ + cad + """" ' Condicion a cumplir
    Dim Utils = New Utils
    ct.DrawingOptions.FillColor = Utils.ColorByName(tkMapColor.Green) 'pintamos el poligono
    sfWorld.Categories.ApplyExpression(0) ' aplicamoS la expresion en el indice seleccionado

End Sub

I want to fill more than one at a time

You can use sf.Categories.Generate(fieldIndex, tkClassificationType.ctUniqueValues, 0); and set ClassificationType to ctUniqueValues

I see we don’t have a full example. I’ll add it to my todo-list to create an example and add it to the documentation

Hello Pmeems
I appreciate it if you can share the example, I’ll wait for the example.
I’ll try with your suggestion
Thanks so much

i try it but paint all the polygons, i want to control which polygons to paint for example the 10,07,20 of the CVE_ENT index with a query, is it possible?
regards and thank you

    AxMap1.Projection = tkMapProjection.PROJECTION_NONE
    AxMap1.GrabProjectionFromData = True

    Dim fieldIndex As New Integer
    fieldIndex = sfWorld.Table.FieldIndexByName("CVE_ENT")
    sfWorld.Categories.Generate(fieldIndex, tkClassificationType.ctUniqueValues, 0)

    Dim scheme = New Mapwingis.ColorScheme()
    scheme.SetColors2(tkMapColor.Blue, tkMapColor.Yellow)
    sfWorld.Categories.ApplyColorScheme(tkColorSchemeType.ctSchemeRandom, scheme)


I want something like that, can you help me with an example or code please

Then you need to create a category and set its expression.
For each color you need to make a new category.

Here’s an example: SelectByDistance.cs

1 Like

Thank you so much, Mapwingis is awesome

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.