# Use set\_ShapeFillColor new version

**URL:** <https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165>\
**Category:** MapWinGIS\
**Created:** [May 21, 2019, 6:40pm UTC](https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165 "2019-05-21T18:40:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luffy\_7557](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@luffy\_7557](https://mapwindow.discourse.group/u/luffy_7557)\
**Post date:** [May 21, 2019, 6:40pm UTC](https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165/1 "2019-05-21T18:40:20Z")

</div>

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

```

 ![map](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/f1a8410148aba0debff3936aeee93b4fc40f422f.png)

I want to fill more than one at a time

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [May 22, 2019, 9:40am UTC](https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165/2 "2019-05-22T09:40:17Z")

</div>

You can use [sf.Categories.Generate(fieldIndex, tkClassificationType.ctUniqueValues, 0);](https://www.mapwindow.org/documentation/mapwingis4.9/class_shapefile_categories.html#ad9331a3944335049fed19886df1e5049) and set ClassificationType to [ctUniqueValues](https://www.mapwindow.org/documentation/mapwingis4.9/_enumerations_8cs.html#a44a53188d5016c1795c9c46578233f86)

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

---

<div class="post-metadata">

**Author:** ![luffy\_7557](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@luffy\_7557](https://mapwindow.discourse.group/u/luffy_7557)\
**Post date:** [May 22, 2019, 3:00pm UTC](https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165/3 "2019-05-22T15:00:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![luffy\_7557](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@luffy\_7557](https://mapwindow.discourse.group/u/luffy_7557)\
**Post date:** [May 22, 2019, 7:39pm UTC](https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165/4 "2019-05-22T19:39:54Z")

</div>

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)

```

 ![map1](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/77ee33a6776643a8b81d881e950760ab3f0df4d2.png)  
 ![table](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/347c741cc3b68bce5e3fedbf36893b12b9da1000.png)

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

 ![map3](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/d6ee098ebf2fb85bd5371f157fe8b7ffdc8493c7.png)

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [May 24, 2019, 6:46am UTC](https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165/5 "2019-05-24T06:46:15Z")

</div>

Then you need to [create a category](https://www.mapwindow.org/documentation/mapwingis4.9/class_shapefile_categories.html#a510573323061bec433991391a167241f) and set its [expression](https://www.mapwindow.org/documentation/mapwingis4.9/class_shapefile_category.html#a1a79f30a010b4dda16c4cf91ccc935da).  
For each color you need to make a new category.

Here’s an example: [SelectByDistance.cs](https://www.mapwindow.org/documentation/mapwingis4.9/_select_by_distance_8cs-example.html)

---

<div class="post-metadata">

**Author:** ![luffy\_7557](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@luffy\_7557](https://mapwindow.discourse.group/u/luffy_7557)\
**Post date:** [May 25, 2019, 4:11pm UTC](https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165/6 "2019-05-25T16:11:53Z")

</div>

Thank you so much, Mapwingis is awesome

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [May 28, 2019, 4:11pm UTC](https://mapwindow.discourse.group/t/use-set-shapefillcolor-new-version/165/7 "2019-05-28T16:11:59Z")

</div>

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