The general steps for creating new elements and setting styles are as follows:
1. Create a new graphic element (lineelement, markerelement, polygonelement, textelement, etc)
2. Create appropriate new symbols for new elements (such as linesymbol, textsymbol, and fillsymbol)
3. Create a new color object (rgbcolor, cmycolor, hlscolor, hsycolor)
4. Define the color value
5. Assign the color to the symbol
6. Define the symbolic style
7. assign a symbol to a Graphic Element
Ielement pelement;
Itextelement ptextelement = new textelementclass ();
Pelement = ptextelement as ielement;
Icolor ptextcolor = new rgbcolor ();
Ptextcolor. RGB = color. froma #000000. toargb ();
Stdole. ifontdisp pfont = new stdole. stdfontclass () as stdole. ifontdisp;
Pfont. size = 20;
Itextsymbol ptextsymbol = new textsymbol ();
Ptextsymbol. Color = ptextcolor;
Ptextsymbol. font = pfont;
Ptextsymbol. horizontalalignment = esritexthorizontalalignment. esrithacenter; // center horizontally
Ptextsymbol. verticalalignment = esritextverticalalignment. esritvatop; // vertically aligned
Ptextelement. Text = "Graphic Element ";
Ptextelement. symbol = ptextsymbol;
Ipoint PPT = new pointclass ();
PPT. x = (pmapframeelementenvelope. xmin + pmapframeelementenvelope. xmax)/2;
PPT. Y = pmapframeelementenvelope. ymin;
Pelement. Geometry = PPT;
Pelemprops = (ielementproperties) pelement;
Pelemprops. Name = "textelement"; // set the element name
Itransform2d ptransform2d = ptextelement as itransform2d;
Ptransform2d. Rotate (PPT, system. Math. PI/2); // Rotate 90 degrees
Igraphicscontainer pgraphicscont = (igraphicscontainer) axpagelayoutcontrol1.pagelayout; // axmapcontrol. Map
Pgraphicscont. addelement (ielement) ptextelement, 0 );