Page 1 of 1

Color of polygon

Posted: Thu May 28, 2009 2:40 pm
by 13051613
How I can change the color of a polygon?

I'm using this code:

Code: Select all

                map2.Shapes(i).Brush.Gradient.StartColor = Color.Red
                map2.Shapes(i).Brush.Gradient.EndColor = Color.Red
this doesn't works.

If I want to change the colors using the properties window in execution time, I have to change the gradient colors a lot of time before the chart makes me case.

Posted: Fri May 29, 2009 9:13 am
by 10050769
Hello Pujol1986,


If you want to change Gradient you could make similar code as next:

Code: Select all

        map1.Brush.Gradient.Visible = True
        map1.Brush.Gradient.StartColor = Color.Red
        map1.Brush.Gradient.EndColor = Color.White
But, if you want change the color of series you needs use only this lines of code:

Code: Select all

        map1.UseColorRange = False
        map1.Color = Color.Red
If I want to change the colors using the properties window in execution time, I have to change the gradient colors a lot of time before the chart makes me case.
I could reproduce your problem, and I have added to enhancement list.

I hope that will helps,


Thanks,

Posted: Fri May 29, 2009 9:39 am
by 13051613
Hello Sandra,

Your code changes the color of all polygons in the chart, and I want to change the color of specific polygon.

for example:

Code: Select all

   For i = 0 To 10
               If i Mod 2 = 0 Then
                    map2.Shapes(i).Brush.Gradient.StartColor = Color.Red
                    map2.Shapes(i).Brush.Gradient.EndColor = Color.Red
                ElseIf i Mod 5 = 0 Then
                    map2.Shapes(i).Brush.Gradient.StartColor = Color.Green
                    map2.Shapes(i).Brush.Gradient.EndColor = Color.Green
                End If
  Next i
I've tried to change the gradient color because this code doesn't work

Code: Select all

   For i = 0 To 10
                  map2.Shapes(i).Color = Color.Green
  Next i
How I can change the color of specific polygon?

Thanks in advance.

Posted: Fri May 29, 2009 10:38 am
by 10050769
Hello Pujol1986,

I make simple example, that I think solve your issue. Please check next code works fine in your application.

Code: Select all

            If i Mod 2 = 0 Then
                map1.Shapes(i).ParentBrush = False
                map1.Shapes(i).Brush.Color = Color.Red
            ElseIf i Mod 5 = 0 Then
                map1.Shapes(i).ParentBrush = False
                map1.Shapes(i).Brush.Color = Color.Green
            End If

Always, you want change the brush(color,gradient,etc)in the run time you needs put property ParentBrush= False.

Also, if you can use gradient you needs put Gradient.Visible= true, see next code:

Code: Select all

    
                map1.Shapes(i).ParentBrush = False
                map1.Shapes(i).Brush.Gradient.Visible = True
                map1.Shapes(i).Brush.Gradient.StartColor = Color.Green
                map1.Shapes(i).Brush.Gradient.EndColor = Color.White

I hope that will helps,

Thanks,

Posted: Fri May 29, 2009 2:53 pm
by 13051613
the code works perfectly.

thanks Sandra