Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
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

1 solution

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);
            }
        }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900