<p>I'd like to create a module in DNN that, similar to the Announcements control, offers a template that the portal admin can modify for formatting.  I have a control that currently uses a Repeater control with templates.  Is there a way to override the contents of the repeater ItemTemplate, HeaderTemplate, and FooterTemplate properties? </p>

[{'answer_id': 5629954, 'author': 'swajak', 'author_id': 100258, 'author_profile': 'https://Stackoverflow.com/users/100258', 'pm_score': 1, 'selected': False, 'text': "<p>I'm not sure this applies to every case, but thanks to this thread, we quickly hooked into the Paint event programmatically using:</p>\n\n<pre><code>GroupBox box = new GroupBox();\n[...]\nbox.Paint += delegate(object o, PaintEventArgs p)\n{\n    p.Graphics.Clear(someColorHere);\n};\n</code></pre>\n\n<p>Cheers!</p>\n"}, {'answer_id': 5827166, 'author': 'Mick Bruno', 'author_id': 730366, 'author_profile': 'https://Stackoverflow.com/users/730366', 'pm_score': 6, 'selected': True, 'text': '<p>Building on the previous answer, a better solution that includes the label for the group box:</p>\n\n<pre><code>groupBox1.Paint += PaintBorderlessGroupBox;\n\nprivate void PaintBorderlessGroupBox(object sender, PaintEventArgs p)\n{\n  GroupBox box = (GroupBox)sender;\n  p.Graphics.Clear(SystemColors.Control);\n  p.Graphics.DrawString(box.Text, box.Font, Brushes.Black, 0, 0);\n}\n</code></pre>\n\n<p>You might want to adjust the x/y for the text, but for my use this is just right.</p>\n'}, {'answer_id': 13653500, 'author': 'Andy', 'author_id': 1867592, 'author_profile': 'https://Stackoverflow.com/users/1867592', 'pm_score': 3, 'selected': False, 'text': '<p>Just set the paint action on any object (not just buttons) to this method to draw a border.</p>\n\n<pre><code>    private void UserControl1_Paint(object sender, PaintEventArgs e)\n    {\n        ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);\n\n    }\n</code></pre>\n\n<p>It still wont be pretty and rounded like the original, but it is much simpler.</p>\n'}, {'answer_id': 20042058, 'author': 'user1944617', 'author_id': 1944617, 'author_profile': 'https://Stackoverflow.com/users/1944617', 'pm_score': 5, 'selected': False, 'text': '<p>Just add paint event.</p>\n\n<pre><code>    private void groupBox1_Paint(object sender, PaintEventArgs e)\n    {\n        GroupBox box = sender as GroupBox;\n        DrawGroupBox(box, e.Graphics, Color.Red, Color.Blue);\n    }\n\n\n    private void DrawGroupBox(GroupBox box, Graphics g, Color textColor, Color borderColor)\n    {\n        if (box != null)\n        {\n            Brush textBrush = new SolidBrush(textColor);\n            Brush borderBrush = new SolidBrush(borderColor);\n            Pen borderPen = new Pen(borderBrush);\n            SizeF strSize = g.MeasureString(box.Text, box.Font);\n            Rectangle rect = new Rectangle(box.ClientRectangle.X,\n                                           box.ClientRectangle.Y + (int)(strSize.Height / 2),\n                                           box.ClientRectangle.Width - 1,\n                                           box.ClientRectangle.Height - (int)(strSize.Height / 2) - 1);\n\n            // Clear text and border\n            g.Clear(this.BackColor);\n\n            // Draw text\n            g.DrawString(box.Text, box.Font, textBrush, box.Padding.Left, 0);\n\n            // Drawing Border\n            //Left\n            g.DrawLine(borderPen, rect.Location, new Point(rect.X, rect.Y + rect.Height));\n            //Right\n            g.DrawLine(borderPen, new Point(rect.X + rect.Width, rect.Y), new Point(rect.X + rect.Width, rect.Y + rect.Height));\n            //Bottom\n            g.DrawLine(borderPen, new Point(rect.X, rect.Y + rect.Height), new Point(rect.X + rect.Width, rect.Y + rect.Height));\n            //Top1\n            g.DrawLine(borderPen, new Point(rect.X, rect.Y), new Point(rect.X + box.Padding.Left, rect.Y));\n            //Top2\n            g.DrawLine(borderPen, new Point(rect.X + box.Padding.Left + (int)(strSize.Width), rect.Y), new Point(rect.X + rect.Width, rect.Y));\n        }\n    }\n</code></pre>\n'}, {'answer_id': 50451872, 'author': 'George', 'author_id': 5077953, 'author_profile': 'https://Stackoverflow.com/users/5077953', 'pm_score': 1, 'selected': False, 'text': '<p>I have achieved same border with something which might be simpler to understand for newbies: </p>\n\n<pre><code>    private void groupSchitaCentru_Paint(object sender, PaintEventArgs e)\n    {\n        Pen blackPen = new Pen(Color.Black, 2);\n        Point pointTopLeft = new Point(0, 7);\n        Point pointBottomLeft = new Point(0, groupSchitaCentru.ClientRectangle.Height);\n        Point pointTopRight = new Point(groupSchitaCentru.ClientRectangle.Width, 7);\n        Point pointBottomRight = new Point(groupSchitaCentru.ClientRectangle.Width, groupSchitaCentru.ClientRectangle.Height);\n\n        e.Graphics.DrawLine(blackPen, pointTopLeft, pointBottomLeft);\n        e.Graphics.DrawLine(blackPen, pointTopLeft, pointTopRight);\n        e.Graphics.DrawLine(blackPen, pointBottomRight, pointTopRight);\n        e.Graphics.DrawLine(blackPen, pointBottomLeft, pointBottomRight);\n    }\n</code></pre>\n\n<ol>\n<li>Set the Paint event on the GroupBox control. In this example the name of my control is "groupSchitaCentru". One needs this event because of its parameter e.</li>\n<li>Set up a pen object by making use of the System.Drawing.Pen class : <a href="https://msdn.microsoft.com/en-us/library/f956fzw1(v=vs.110).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/f956fzw1(v=vs.110).aspx</a></li>\n<li>Set the points which represent the corners of the rectangle represented by the control. Used the property ClientRectangle of the the control to get its dimensions.\nI used for TopLeft (0,7) because I want to respect the borders of the control, and draw the line about the its text.\nTo get more information about the coordinates system walk here : <a href="https://learn.microsoft.com/en-us/dotnet/framework/winforms/windows-forms-coordinates" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dotnet/framework/winforms/windows-forms-coordinates</a></li>\n</ol>\n\n<p>I do not know, may be it helps someone looking to  achieve this border adjustment thing.</p>\n'}, {'answer_id': 51663475, 'author': 'NetXpert', 'author_id': 1542024, 'author_profile': 'https://Stackoverflow.com/users/1542024', 'pm_score': 3, 'selected': False, 'text': '<p>FWIW, this is the implementation I used. It\'s a child of GroupBox but allows setting not only the BorderColor, but also the thickness of the border and the radius of the rounded corners. Also, you can set the amount of indent you want for the GroupBox label, and using a negative indent indents from the right side.</p>\n\n<pre><code>using System;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace BorderedGroupBox\n{\n    public class BorderedGroupBox : GroupBox\n    {\n        private Color _borderColor = Color.Black;\n        private int _borderWidth = 2;\n        private int _borderRadius = 5;\n        private int _textIndent = 10;\n\n        public BorderedGroupBox() : base()\n        {\n            InitializeComponent();\n            this.Paint += this.BorderedGroupBox_Paint;\n        }\n\n        public BorderedGroupBox(int width, float radius, Color color) : base()\n        {\n            this._borderWidth = Math.Max(1,width);\n            this._borderColor = color;\n            this._borderRadius = Math.Max(0,radius);\n            InitializeComponent();\n            this.Paint += this.BorderedGroupBox_Paint;\n        }\n\n        public Color BorderColor\n        {\n            get =&gt; this._borderColor;\n            set\n            {\n                this._borderColor = value;\n                DrawGroupBox();\n            }\n        }\n\n        public int BorderWidth\n        {\n            get =&gt; this._borderWidth;\n            set\n            {\n                if (value &gt; 0)\n                {\n                    this._borderWidth = Math.Min(value, 10);\n                    DrawGroupBox();\n                }\n            }\n        }\n\n        public int BorderRadius\n        {\n            get =&gt; this._borderRadius;\n            set\n            {   // Setting a radius of 0 produces square corners...\n                if (value &gt;= 0)\n                {\n                    this._borderRadius = value;\n                    this.DrawGroupBox();\n                }\n            }\n        }\n\n        public int LabelIndent\n        {\n            get =&gt; this._textIndent;\n            set\n            {\n                this._textIndent = value;\n                this.DrawGroupBox();\n            }\n        }\n\n        private void BorderedGroupBox_Paint(object sender, PaintEventArgs e) =&gt;\n            DrawGroupBox(e.Graphics);\n\n        private void DrawGroupBox() =&gt;\n            this.DrawGroupBox(this.CreateGraphics());\n\n        private void DrawGroupBox(Graphics g)\n        {\n            Brush textBrush = new SolidBrush(this.ForeColor);\n            SizeF strSize = g.MeasureString(this.Text, this.Font);\n\n            Brush borderBrush = new SolidBrush(this.BorderColor);\n            Pen borderPen = new Pen(borderBrush,(float)this._borderWidth);\n            Rectangle rect = new Rectangle(this.ClientRectangle.X,\n                                            this.ClientRectangle.Y + (int)(strSize.Height / 2),\n                                            this.ClientRectangle.Width - 1,\n                                            this.ClientRectangle.Height - (int)(strSize.Height / 2) - 1);\n\n            Brush labelBrush = new SolidBrush(this.BackColor);\n\n            // Clear text and border\n            g.Clear(this.BackColor);\n\n            // Drawing Border (added "Fix" from Jim Fell, Oct 6, \'18)\n            int rectX = (0 == this._borderWidth % 2) ? rect.X + this._borderWidth / 2 : rect.X + 1 + this._borderWidth / 2;\n            int rectHeight = (0 == this._borderWidth % 2) ? rect.Height - this._borderWidth / 2 : rect.Height - 1 - this._borderWidth / 2;\n            // NOTE DIFFERENCE: rectX vs rect.X and rectHeight vs rect.Height\n            g.DrawRoundedRectangle(borderPen, rectX, rect.Y, rect.Width, rectHeight, (float)this._borderRadius);\n\n            // Draw text\n            if (this.Text.Length &gt; 0)\n            {\n                // Do some work to ensure we don\'t put the label outside\n                // of the box, regardless of what value is assigned to the Indent:\n                int width = (int)rect.Width, posX;\n                posX = (this._textIndent &lt; 0) ? Math.Max(0-width,this._textIndent) : Math.Min(width, this._textIndent);\n                posX = (posX &lt; 0) ? rect.Width + posX - (int)strSize.Width : posX;\n                g.FillRectangle(labelBrush, posX, 0, strSize.Width, strSize.Height);\n                g.DrawString(this.Text, this.Font, textBrush, posX, 0);\n            }\n        }\n\n        #region Component Designer generated code\n        /// &lt;summary&gt;Required designer variable.&lt;/summary&gt;\n        private System.ComponentModel.IContainer components = null;\n\n        /// &lt;summary&gt;Clean up any resources being used.&lt;/summary&gt;\n        /// &lt;param name="disposing"&gt;true if managed resources should be disposed; otherwise, false.&lt;/param&gt;\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing &amp;&amp; (components != null))\n                components.Dispose();\n\n            base.Dispose(disposing);\n        }\n\n        /// &lt;summary&gt;Required method for Designer support - Don\'t modify!&lt;/summary&gt;\n        private void InitializeComponent() =&gt; components = new System.ComponentModel.Container();\n        #endregion\n    }\n}\n</code></pre>\n\n<p>To make it work, you also have to extend the base Graphics class (Note: this is derived from some code I found on here once when I was trying to create a rounded-corners Panel control, but I can\'t find the original post to link here):</p>\n\n<pre><code>static class GraphicsExtension\n{\n    private static GraphicsPath GenerateRoundedRectangle(\n        this Graphics graphics,\n        RectangleF rectangle,\n        float radius)\n    {\n        float diameter;\n        GraphicsPath path = new GraphicsPath();\n        if (radius &lt;= 0.0F)\n        {\n            path.AddRectangle(rectangle);\n            path.CloseFigure();\n            return path;\n        }\n        else\n        {\n            if (radius &gt;= (Math.Min(rectangle.Width, rectangle.Height)) / 2.0)\n                return graphics.GenerateCapsule(rectangle);\n            diameter = radius * 2.0F;\n            SizeF sizeF = new SizeF(diameter, diameter);\n            RectangleF arc = new RectangleF(rectangle.Location, sizeF);\n            path.AddArc(arc, 180, 90);\n            arc.X = rectangle.Right - diameter;\n            path.AddArc(arc, 270, 90);\n            arc.Y = rectangle.Bottom - diameter;\n            path.AddArc(arc, 0, 90);\n            arc.X = rectangle.Left;\n            path.AddArc(arc, 90, 90);\n            path.CloseFigure();\n        }\n        return path;\n    }\n\n    private static GraphicsPath GenerateCapsule(\n        this Graphics graphics,\n        RectangleF baseRect)\n    {\n        float diameter;\n        RectangleF arc;\n        GraphicsPath path = new GraphicsPath();\n        try\n        {\n            if (baseRect.Width &gt; baseRect.Height)\n            {\n                diameter = baseRect.Height;\n                SizeF sizeF = new SizeF(diameter, diameter);\n                arc = new RectangleF(baseRect.Location, sizeF);\n                path.AddArc(arc, 90, 180);\n                arc.X = baseRect.Right - diameter;\n                path.AddArc(arc, 270, 180);\n            }\n            else if (baseRect.Width &lt; baseRect.Height)\n            {\n                diameter = baseRect.Width;\n                SizeF sizeF = new SizeF(diameter, diameter);\n                arc = new RectangleF(baseRect.Location, sizeF);\n                path.AddArc(arc, 180, 180);\n                arc.Y = baseRect.Bottom - diameter;\n                path.AddArc(arc, 0, 180);\n            }\n            else path.AddEllipse(baseRect);\n        }\n        catch { path.AddEllipse(baseRect); }\n        finally { path.CloseFigure(); }\n        return path;\n    }\n\n    /// &lt;summary&gt;\n    /// Draws a rounded rectangle specified by a pair of coordinates, a width, a height and the radius\n    /// for the arcs that make the rounded edges.\n    /// &lt;/summary&gt;\n    /// &lt;param name="brush"&gt;System.Drawing.Pen that determines the color, width and style of the rectangle.&lt;/param&gt;\n    /// &lt;param name="x"&gt;The x-coordinate of the upper-left corner of the rectangle to draw.&lt;/param&gt;\n    /// &lt;param name="y"&gt;The y-coordinate of the upper-left corner of the rectangle to draw.&lt;/param&gt;\n    /// &lt;param name="width"&gt;Width of the rectangle to draw.&lt;/param&gt;\n    /// &lt;param name="height"&gt;Height of the rectangle to draw.&lt;/param&gt;\n    /// &lt;param name="radius"&gt;The radius of the arc used for the rounded edges.&lt;/param&gt;\n    public static void DrawRoundedRectangle(\n        this Graphics graphics,\n        Pen pen,\n        float x,\n        float y,\n        float width,\n        float height,\n        float radius)\n    {\n        RectangleF rectangle = new RectangleF(x, y, width, height);\n        GraphicsPath path = graphics.GenerateRoundedRectangle(rectangle, radius);\n        SmoothingMode old = graphics.SmoothingMode;\n        graphics.SmoothingMode = SmoothingMode.AntiAlias;\n        graphics.DrawPath(pen, path);\n        graphics.SmoothingMode = old;\n    }\n\n    /// &lt;summary&gt;\n    /// Draws a rounded rectangle specified by a pair of coordinates, a width, a height and the radius\n    /// for the arcs that make the rounded edges.\n    /// &lt;/summary&gt;\n    /// &lt;param name="brush"&gt;System.Drawing.Pen that determines the color, width and style of the rectangle.&lt;/param&gt;\n    /// &lt;param name="x"&gt;The x-coordinate of the upper-left corner of the rectangle to draw.&lt;/param&gt;\n    /// &lt;param name="y"&gt;The y-coordinate of the upper-left corner of the rectangle to draw.&lt;/param&gt;\n    /// &lt;param name="width"&gt;Width of the rectangle to draw.&lt;/param&gt;\n    /// &lt;param name="height"&gt;Height of the rectangle to draw.&lt;/param&gt;\n    /// &lt;param name="radius"&gt;The radius of the arc used for the rounded edges.&lt;/param&gt;\n\n    public static void DrawRoundedRectangle(\n        this Graphics graphics,\n        Pen pen,\n        int x,\n        int y,\n        int width,\n        int height,\n        int radius)\n    {\n        graphics.DrawRoundedRectangle(\n            pen,\n            Convert.ToSingle(x),\n            Convert.ToSingle(y),\n            Convert.ToSingle(width),\n            Convert.ToSingle(height),\n            Convert.ToSingle(radius));\n    }\n}\n</code></pre>\n'}, {'answer_id': 68691524, 'author': 'compound eye', 'author_id': 133507, 'author_profile': 'https://Stackoverflow.com/users/133507', 'pm_score': 0, 'selected': False, 'text': "<p>This tweak to Jim Fell's code placed the borders a little better for me, but it's too long to add as a comment</p>\n<p>...</p>\n<pre><code>   Rectangle rect = new Rectangle(this.ClientRectangle.X,\n                                        this.ClientRectangle.Y + (int)(strSize.Height / 2),\n                                        this.ClientRectangle.Width,\n                                        this.ClientRectangle.Height - (int)(strSize.Height / 2));\n\n    Brush labelBrush = new SolidBrush(this.BackColor);\n\n    // Clear text and border\n    g.Clear(this.BackColor);\n\n\n    int drawX = rect.X;\n    int drawY = rect.Y;\n    int drawWidth = rect.Width;\n    int drawHeight = rect.Height;\n\n    if (this._borderWidth &gt; 0)\n    {\n        drawX += this._borderWidth / 2;\n        drawY += this._borderWidth / 2;\n\n        drawWidth -= this._borderWidth;\n        drawHeight -= this._borderWidth;\n        \n        if (this._borderWidth % 2 == 0)\n        {\n            drawX -= 1;\n            drawWidth += 1;\n\n            drawY -= 1;\n            drawHeight += 1;\n        }\n    }\n\n    g.DrawRoundedRectangle(borderPen, drawX, drawY, drawWidth, drawHeight, (float)this._borderRadius);\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/76464', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13100/']