Click here to Skip to main content
15,903,030 members
Home / Discussions / C#
   

C#

 
GeneralRe: modifying a html file in windows c# application Pin
Suunil18-May-10 3:11
Suunil18-May-10 3:11 
GeneralRe: modifying a html file in windows c# application Pin
T M Gray18-May-10 5:10
T M Gray18-May-10 5:10 
AnswerRe: modifying a html file in windows c# application Pin
Not Active18-May-10 3:54
mentorNot Active18-May-10 3:54 
AnswerRe: modifying a html file in windows c# application Pin
Suunil20-May-10 3:02
Suunil20-May-10 3:02 
QuestionReading integer from an xml file Pin
acont18-May-10 2:41
acont18-May-10 2:41 
AnswerRe: Reading integer from an xml file Pin
Seishin#18-May-10 4:40
Seishin#18-May-10 4:40 
GeneralRe: Reading integer from an xml file Pin
acont18-May-10 5:23
acont18-May-10 5:23 
AnswerRe: Reading integer from an xml file Pin
PIEBALDconsult18-May-10 4:56
mvePIEBALDconsult18-May-10 4:56 
QuestionPlz, des'nt File Delete ,, [modified] Pin
sonic74718-May-10 0:25
sonic74718-May-10 0:25 
AnswerFile not deleting [modified] Pin
DaveyM6918-May-10 0:32
professionalDaveyM6918-May-10 0:32 
GeneralRe: File not deleting Pin
Johnny J.18-May-10 1:25
professionalJohnny J.18-May-10 1:25 
GeneralRe: File not deleting Pin
DaveyM6918-May-10 2:08
professionalDaveyM6918-May-10 2:08 
AnswerRe: Plz, des'nt File Delete ,, Pin
Luc Pattyn18-May-10 1:10
sitebuilderLuc Pattyn18-May-10 1:10 
AnswerRe: Plz, des'nt File Delete ,, Pin
sonic74718-May-10 1:30
sonic74718-May-10 1:30 
GeneralRe: Plz, des'nt File Delete ,, Pin
Not Active18-May-10 2:41
mentorNot Active18-May-10 2:41 
GeneralRe: Plz, des'nt File Delete ,, Pin
William Winner18-May-10 7:29
William Winner18-May-10 7:29 
AnswerRe: Plz, des'nt File Delete ,, Pin
Seishin#18-May-10 4:39
Seishin#18-May-10 4:39 
QuestionCombobox SelectedValue Problem. Pin
Dotnetkanna17-May-10 23:30
Dotnetkanna17-May-10 23:30 
AnswerRe: Combobox SelectedValue Problem. Pin
Abhinav S18-May-10 0:34
Abhinav S18-May-10 0:34 
AnswerRe: Combobox SelectedValue Problem. Pin
Seishin#18-May-10 4:46
Seishin#18-May-10 4:46 
QuestionHow can save picturebox image using menustrip Pin
Nivas8217-May-10 21:00
Nivas8217-May-10 21:00 
AnswerRe: How can save picturebox image using menustrip Pin
William Winner18-May-10 8:00
William Winner18-May-10 8:00 
You're going to have some problems with the method you're using if you want to save it.

The best thing that I can suggest to do is to create an intermediate Bitmap to draw on and set your PictureBox1.Image value to that Bitmap. Then, you can save it pretty easily. For example:
C#
Rectangle rect = New Rectangle(0,0,0,0);
Bitmap myBitmap;

private void PictureBox_MouseDown(object sender, MouseEventArgs e)
{
  if (myBitmap == null)
  {
    myBitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height, PictureBox1.CreateGraphics());
    PictureBox1.Image = myBitmap;
  }

  rect = New Rectangle(e.X, e.Y, 0, 0);
  PictureBox1.Invalidate();
}

private void PictureBox_MouseMove(object sender, MouseEventArgs e)
{
  if (e.Button == MouseButtons.Left)
  {
    rect = New Rectangle(rect.Left, rect.Top, e.X - rect.Left, e.Y - rect.Top);
    PictureBox1.Invalidate();
  }
}

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

    using (Pen pen = New Pen(Color.Red, 2))
    {
      using (Graphics g = Graphics.FromImage(myBitmap))
      {
        g.Clear(Color.White);
        g.DrawRectangle(pen, rect);
      }
    }
}

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
  if (myBitmap != null)
  {
    myBitmap.Save("D:\\Temp\\Bitmapsave.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  }
}


It's basically the same thing you've done, except instead of drawing on the bitmap instead of directly on the PaintBox.
GeneralRe: How can save picturebox image using menustrip Pin
Nivas8218-May-10 19:18
Nivas8218-May-10 19:18 
GeneralRe: How can save picturebox image using menustrip Pin
William Winner19-May-10 5:29
William Winner19-May-10 5:29 
GeneralRe: How can save picturebox image using menustrip Pin
Nivas8219-May-10 23:13
Nivas8219-May-10 23:13 

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.