Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. create customize control

create customize control

Scheduled Pinned Locked Moved C#
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Naveed727
    wrote on last edited by
    #1

    How can i create an customize label with surrounded rectangle.

    L 1 Reply Last reply
    0
    • N Naveed727

      How can i create an customize label with surrounded rectangle.

      L Offline
      L Offline
      Lev Danielyan
      wrote on last edited by
      #2

      You can inherit a control from System.Windows.Forms.Label and override its OnPaint event:

      // Constructor
      public BorderLabel() {
      InitializeComponent();
      this.Paint += new System.Windows.Forms.PaintEventHandler(BorderLabel_Paint);
      }

      // Event
      void BorderLabel_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
      Brush brush = new SolidBrush(Color.Red);
      Pen pen = new Pen(brush);
      Rectangle rect = e.ClipRectangle;

      // this is needed to see the right and bottom edges
      rect.Inflate(-1, -1);

      e.Graphics.DrawRectangle(pen, rect);
      }

      Regards, Lev

      modified on Thursday, January 8, 2009 6:15 AM

      D 1 Reply Last reply
      0
      • L Lev Danielyan

        You can inherit a control from System.Windows.Forms.Label and override its OnPaint event:

        // Constructor
        public BorderLabel() {
        InitializeComponent();
        this.Paint += new System.Windows.Forms.PaintEventHandler(BorderLabel_Paint);
        }

        // Event
        void BorderLabel_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
        Brush brush = new SolidBrush(Color.Red);
        Pen pen = new Pen(brush);
        Rectangle rect = e.ClipRectangle;

        // this is needed to see the right and bottom edges
        rect.Inflate(-1, -1);

        e.Graphics.DrawRectangle(pen, rect);
        }

        Regards, Lev

        modified on Thursday, January 8, 2009 6:15 AM

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        Lev Danielyan wrote:

        OnPain event

        I know that one well! :laugh:

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

        L 1 Reply Last reply
        0
        • D DaveyM69

          Lev Danielyan wrote:

          OnPain event

          I know that one well! :laugh:

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

          L Offline
          L Offline
          Lev Danielyan
          wrote on last edited by
          #4

          I wish I did it on purpose :laugh: :laugh:

          Regards, Lev

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups