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

C#

 
GeneralRe: form minimized Pin
Luc Pattyn27-Jun-07 7:37
sitebuilderLuc Pattyn27-Jun-07 7:37 
QuestionDeleting a dynamically created Excel file Pin
snir_ya27-Jun-07 3:20
snir_ya27-Jun-07 3:20 
AnswerRe: Deleting a dynamically created Excel file Pin
Jimmanuel27-Jun-07 3:55
Jimmanuel27-Jun-07 3:55 
GeneralRe: Deleting a dynamically created Excel file Pin
snir_ya27-Jun-07 5:28
snir_ya27-Jun-07 5:28 
AnswerRe: Deleting a dynamically created Excel file Pin
mnaveed27-Jun-07 5:55
mnaveed27-Jun-07 5:55 
QuestionHow to create slip definition files in C# Pin
AR Reddy27-Jun-07 2:54
AR Reddy27-Jun-07 2:54 
JokeRe: How to create slip definition files in C# Pin
mav.northwind27-Jun-07 8:28
mav.northwind27-Jun-07 8:28 
QuestionProblem about bitmap in Visual Studio C Sharp.NET ? Pin
zeeShan anSari27-Jun-07 2:15
zeeShan anSari27-Jun-07 2:15 
Hi friends,Smile | :)
I am designing a paint brush type program…..for drawing area where I can draw something then I used pictureBox…..like as
Pen p = new Pen(Color.Red, 5);<br />
g = pictureBox2.CreateGraphics();<br />
g.DrawEllipse(p, e.X, e.Y, 5, 7); 



in this program I can draw anything but when I want to save this drawing by the help of this command: pictureBox2.Image.Save(saveFileDialog1.FileName);

then an error occur : “NullReferenceExpection was unhandled !”Object reference not set to an instance of an object.”

i got the solution of above problem like as:
Bitmap bmp = new Bitmap(pictureBox2.Width, pictureBox2.Height);<br />
Graphics g = Graphics.FromImage(bmp);<br />
Pen p = new Pen(Color.Red, 5);<br />
g.DrawEllipse(p, e.X, e.Y, 5, 7); <br />
pictureBox2.Image = bmp;

follwing code solve just half problem...............means save only last ellipse ,but i want whole drawing
private void pictureBox2_MouseDown(object sender, MouseEventArgs e)<br />
        {   <br />
            if (e.Button == MouseButtons.Left)<br />
            {<br />
Bitmap bmp = new Bitmap(pictureBox2.Width, pictureBox2.Height);<br />
<br />
Graphics g = Graphics.FromImage(bmp);<br />
<br />
Pen p = new Pen(Color.Red, 5);<br />
<br />
g.DrawEllipse(p, e.X, e.Y, 5, 7); <br />
           }
---------------------------------------------------------------
and then ......... ... .

if (saveFileDialog1.ShowDialog() == DialogResult.OK)<br />
            {<br />
pictureBox2.Image = bmp;<br />
<br />
pictureBox2.Image.Save(saveFileDialog1.FileName);

}-----------------------------------------------------------------
i think, there is something missing in
Graphics g = Graphics.FromImage(bmp);
or
pictureBox2.Image = bmp;(like: pictureBox2.Image += bmp;but illegal )
-----------------------------------------------------------------
bmp or pictureBox does not update with previous condition
it always losing the previous ellipse and save the last drawn
ellipse
i need your help!
thanksBig Grin | :-D
AnswerRe: Problem about bitmap in Visual Studio C Sharp.NET ? Pin
Martin#27-Jun-07 2:28
Martin#27-Jun-07 2:28 
GeneralRe: Problem about bitmap in Visual Studio C Sharp.NET ? Pin
zeeShan anSari27-Jun-07 3:22
zeeShan anSari27-Jun-07 3:22 
GeneralRe: Problem about bitmap in Visual Studio C Sharp.NET ? Pin
Luc Pattyn27-Jun-07 7:42
sitebuilderLuc Pattyn27-Jun-07 7:42 
GeneralRe: Problem about bitmap in Visual Studio C Sharp.NET ? Pin
Martin#27-Jun-07 19:55
Martin#27-Jun-07 19:55 
AnswerRe: Problem about bitmap in Visual Studio C Sharp.NET ? Pin
Christian Graus27-Jun-07 3:20
protectorChristian Graus27-Jun-07 3:20 
GeneralRe: Problem about bitmap in Visual Studio C Sharp.NET ? Pin
zeeShan anSari27-Jun-07 3:33
zeeShan anSari27-Jun-07 3:33 
QuestionDisplaying data in two grids from three tables Pin
wasife27-Jun-07 1:54
wasife27-Jun-07 1:54 
AnswerRe: Displaying data in two grids from three tables Pin
Dave Sexton27-Jun-07 2:36
Dave Sexton27-Jun-07 2:36 
QuestionSet Encoding for Stream Writer Pin
t4ure4n27-Jun-07 1:07
t4ure4n27-Jun-07 1:07 
AnswerRe: Set Encoding for Stream Writer Pin
leppie27-Jun-07 1:10
leppie27-Jun-07 1:10 
GeneralRe: Set Encoding for Stream Writer Pin
t4ure4n27-Jun-07 1:16
t4ure4n27-Jun-07 1:16 
AnswerRe: Set Encoding for Stream Writer Pin
Guffa27-Jun-07 1:21
Guffa27-Jun-07 1:21 
QuestionGraphics to File Pin
pmartike27-Jun-07 0:58
pmartike27-Jun-07 0:58 
AnswerRe: Graphics to File Pin
Guffa27-Jun-07 1:27
Guffa27-Jun-07 1:27 
GeneralRe: Graphics to File Pin
pmartike27-Jun-07 23:25
pmartike27-Jun-07 23:25 
AnswerRe: Graphics to File Pin
Christian Graus27-Jun-07 1:32
protectorChristian Graus27-Jun-07 1:32 
AnswerRe: Graphics to File Pin
zeeShan anSari27-Jun-07 3:56
zeeShan anSari27-Jun-07 3:56 

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.