MapWinGIS:SampleCode-VB Net:ColorShapes

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

Color Shapes based on DBF Values

This example illustrates the ability of MapWinGIS to color individual shapes in a layer.

     'This example assumes that 'Sown' is in the first column of the dbf 
     Sub ColorSownFields()
         Dim shp As New MapWinGIS.Shapefile
         Dim intLayer, I As Integer
         Dim uColor1, uColor2 As UInt32
         shp.Open("YourFileName.shp", Me)
         intLayer = AxMap1.AddLayer(shp, True)
         uColor1 = Convert.ToUInt32(RGB(255, 0, 0)) 'Red
         'This will also work, depending on what kind of color you want to use 
         uColor2 = Convert.ToUInt32(Drawing.ColorTranslator.ToWin32(Drawing.Color.Yellow)) 'Yellow
         For I = 0 To shp.NumShapes - 1
             If shp.CellValue(1, I) = 1 Then
                 AxMap1.set_ShapeFillColor(intLayer, I, uColor2)
                 AxMap1.set_ShapeFillColor(intLayer, I, uColor1)
             End If
     End Sub

Code submitted by Shade1974 on 12/9/2005

Retrieved from ""

This page has been accessed 3,434 times. This page was last modified on 9 December 2005, at 16:47.