Click here to Skip to main content
15,889,216 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help ploting Excel graph in C# Pin
Henry Minute31-May-10 0:37
Henry Minute31-May-10 0:37 
GeneralRe: Help ploting Excel graph in C# Pin
Mc_Topaz31-May-10 1:10
Mc_Topaz31-May-10 1:10 
GeneralRe: Help ploting Excel graph in C# Pin
Henry Minute31-May-10 1:23
Henry Minute31-May-10 1:23 
GeneralRe: Help ploting Excel graph in C# Pin
Mc_Topaz31-May-10 2:29
Mc_Topaz31-May-10 2:29 
GeneralRe: Help ploting Excel graph in C# Pin
Henry Minute31-May-10 2:51
Henry Minute31-May-10 2:51 
Questiondarw rectangle modification.... [modified] Pin
Nivas8230-May-10 22:42
Nivas8230-May-10 22:42 
AnswerRe: darw rectangle modification.... Pin
OriginalGriff30-May-10 23:00
mveOriginalGriff30-May-10 23:00 
GeneralRe: darw rectangle modification.... Pin
Nivas8231-May-10 18:53
Nivas8231-May-10 18:53 
ok. I will post my rectangle code here...

In my previous post I have solved my problem by making picture box size or bitmap size to image size (Image I load).

now i like to draw multiple rectangle on bitmap. how can i draw. I tried using array in rectangle. but i get error as "Object reference not set to an instance of an object." (Null reference Exception was unhandled).

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (mybitmap == null)
            {
                mybitmap = new Bitmap(sz.Width, sz.Height);
                
            }
            rect[count] = new Rectangle(e.X, e.Y, 0, 0);
            this.Invalidate();


if (stayToolStripMenuItem.Checked == true)
           {
               switch (e.Button)
               {
                   case MouseButtons.Left:
                       {
                           rect[count] = new Rectangle(rect[count].Left, rect[count].Top, e.X - rect[count].Left, e.Y - rect[count].Top);
                           pictureBox1.Invalidate();
                            break;
                       }

                       count++;
               }
           }

private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
if (mybitmap == null)
                {
                    return;
                }


                using (g = Graphics.FromImage(mybitmap))
                {

                    using (Pen pen = new Pen(Color.Red, 2))
                    {
                        g.Clear(Color.Transparent);


                        e.Graphics.DrawRectangle(pen, rect[count]);
                        label1.Top = rect[count].Top; label1.Left = rect[count].Left; label1.Width = rect[count].Width;
                        label1.Height = rect[count].Height;


if (label1.TextAlign == ContentAlignment.TopLeft)
                        {
                            e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect[count]);
                            g.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect[count]);
                            g.DrawRectangle(pen, rect[count]);
                        
                    }
}

GeneralRe: darw rectangle modification.... Pin
OriginalGriff31-May-10 22:13
mveOriginalGriff31-May-10 22:13 
GeneralRe: darw rectangle modification.... Pin
Nivas821-Jun-10 22:17
Nivas821-Jun-10 22:17 
GeneralRe: darw rectangle modification.... Pin
OriginalGriff1-Jun-10 22:59
mveOriginalGriff1-Jun-10 22:59 
AnswerRe: darw rectangle modification.... [modified] Pin
Nivas822-Jun-10 19:18
Nivas822-Jun-10 19:18 
GeneralRe: darw rectangle modification.... Pin
Nivas827-Jun-10 21:39
Nivas827-Jun-10 21:39 
AnswerRe: darw rectangle modification.... Pin
Luc Pattyn31-May-10 1:57
sitebuilderLuc Pattyn31-May-10 1:57 
GeneralRe: darw rectangle modification.... Pin
Nivas8231-May-10 19:02
Nivas8231-May-10 19:02 
GeneralRe: darw rectangle modification.... Pin
Luc Pattyn1-Jun-10 1:48
sitebuilderLuc Pattyn1-Jun-10 1:48 
QuestionA Question Of Focus and Tab Indices [Solved] Pin
Roger Wright30-May-10 22:20
professionalRoger Wright30-May-10 22:20 
AnswerRe: A Question Of Focus and Tab Indices Pin
Henry Minute30-May-10 23:10
Henry Minute30-May-10 23:10 
GeneralRe: A Question Of Focus and Tab Indices [modified] Pin
Roger Wright30-May-10 23:20
professionalRoger Wright30-May-10 23:20 
GeneralRe: A Question Of Focus and Tab Indices Pin
OriginalGriff30-May-10 23:27
mveOriginalGriff30-May-10 23:27 
GeneralRe: A Question Of Focus and Tab Indices Pin
Henry Minute30-May-10 23:30
Henry Minute30-May-10 23:30 
GeneralRe: A Question Of Focus and Tab Indices Pin
Luc Pattyn31-May-10 2:02
sitebuilderLuc Pattyn31-May-10 2:02 
Questiondeclare string[] Pin
jojoba201130-May-10 20:31
jojoba201130-May-10 20:31 
AnswerRe: declare string[] Pin
Vikram A Punathambekar30-May-10 20:34
Vikram A Punathambekar30-May-10 20:34 
AnswerRe: declare string[] Pin
Abhinav S30-May-10 20:43
Abhinav S30-May-10 20:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.