How To Draw Border At PictureBox Border In C#

s

hello i am up with this but this is something very small but very useful ok now what this is about , theres are 2button and a openfiledialog and when you click open the openfiledialog will be up so you just can go ahead and select a image and you click the draw button the picturebox out border will be green color .


add a two buttons and change button1 text to draw and for button 2 text open and adda picturebox and at last add a openfiledialog

you can change the border color just replace green with your color

codes

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

//Author : Mohamed Shimran
//Blog : http://www.ultimateprogrammingtutorials.blogspot.com

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
       {
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                  pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
                }
            }
        private void button1_Click(object sender, EventArgs e)
        {
            Graphics objGraphics = null;
            objGraphics = this.CreateGraphics();
            objGraphics.Clear(SystemColors.Control);
            objGraphics.DrawRectangle(Pens.Green,
                 pictureBox1.Left - 1, pictureBox1.Top - 1,
                  pictureBox1.Width + 1, pictureBox1.Height + 1);
            objGraphics.Dispose();
        }

      
        }
    }

1 comments:

Nice and really very helpful :)

Reply

Post a Comment

Note: Only a member of this blog may post a comment.