Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I Tried setting the color of a added shape to the background color red.
it sets the value and does not show up with the set color.
 
my code is as follow
objShape.get_Cells("FillForegnd").FormulaU = "=RGB(150,10,0)";
objShape.get_Cells("FillPattern").FormulaU = "=RGB(150,10,0)";
 

Any help? What can be the issue?
 
Thanks in advance.
Posted 8-Feb-13 0:04am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I have solved it my self.
 
Found another approach to do this as follows:
 

/// <summary>
        /// This method sets the Given shapes backcolor to the given System.Drawing.Color.
        /// </summary>
        /// <param name="objShape">Shape to be set Backcolor</param>
        /// <param name="ShapeBackColor">System.Drawing.Color to be set as Background color to the given shape.</param>
        private void SetShapeBackColor(Shape objShape, System.Drawing.Color ShapeBackColor)
        {
            try
            {
                int iUndoScopeID;
                byte R = ShapeBackColor.R;
                byte G = ShapeBackColor.G;
                byte B = ShapeBackColor.B;
 
                #region Formation for the Master Shape
                iUndoScopeID = LocationMapPage.Document.BeginUndoScope("Fill Color");
                //Setting Back color to the Maseter Shape
                try { objShape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowFill, (short)VisCellIndices.visFillBkgnd).FormulaU = "THEMEGUARD(RGB(" + R + "," + G + "," + B + "))"; }
                catch (Exception ex) { }
                //Setting Forcolor to the Master Shape.
                try { objShape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowFill, (short)VisCellIndices.visFillForegnd).FormulaU = "THEMEGUARD(RGB(" + R + "," + G + "," + B + "))"; }
                catch (Exception ex) { }
                LocationMapPage.Document.EndUndoScope(iUndoScopeID, true);
                //Setting the Format to false.
                try { objShape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockFormat).FormulaU = "1"; }
                catch (Exception ex) { }
                #endregion
 
                //Setting Colors to all the Containing color in the Master Shape.
                foreach (Shape s in objShape.Shapes)
                {
                    #region Formation for the Sub-Shapes in it.
                    iUndoScopeID = LocationMapPage.Document.BeginUndoScope("Fill Color");
                    //Setting Background Color
                    try { s.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowFill, (short)VisCellIndices.visFillBkgnd).FormulaU = "THEMEGUARD(RGB(" + R + "," + G + "," + B + "))"; }
                    catch (Exception ex) { }
 
                    //Setting ForeGround Color
                    try { s.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowFill, (short)VisCellIndices.visFillForegnd).FormulaU = "THEMEGUARD(RGB(" + R + "," + G + "," + B + "))"; }
                    catch (Exception ex) { }
 
                    //Setting the Fill color
                    LocationMapPage.Document.EndUndoScope(iUndoScopeID, true);
 
                    //Setting the Format to false.
                    try { s.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLock, (short)VisCellIndices.visLockFormat).FormulaU = "1"; }
                    catch (Exception ex) { }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Common.WriteLog("Exception :" + ex);
            }
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 7 Aug 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100