Odd behaviour of Graphics.FromHdc
I develop app for math calculations. You insert calculation code (sequence of formulas) and get BMP output with formulas, substitution, results... 

For smooth experience I draw the BMP in memory and then past it to output:

    DeleteObject(hBMP);     // delete previous hBMP
    hBMP = CreateBitmap(Calculation.Width, Calculation.Height, 1, 32, IntPtr.Zero);
    SelectObject(hDC, hBMP);
    Calculation.G = Graphics.FromHdc(hDC);

    Calculation.G.Clear(Color.White);
    Calculation.DrawBMP(); // complex serie of DrawText, DrawLine etc.

    ...

    OutputGraphics.DrawImageUnscaled(Bitmap.FromHbitmap(hBMP), 0, 0);


The problem:
I can change position of any equation using NumericUpDown. It works perfectly for several times.
Than (totally randomly) just part of the calculation is printed - please see screenshots.
On next position change everything is OK again.

I use Graphics.DrawString, Graphics.DrawLine in Calculation.DrawBMP()

I appreciate any help!

Please see screenshots (change number of image):
http://arb-builder.cz/POM/1.jpg
to 
http://arb-builder.cz/POM/6.jpg

Odd behaviour of Graphics.FromHdc
===

I develop app for math calculations. You insert calculation code (sequence of formulas) and get BMP output with formulas, substitution, results... 

For smooth experience I draw the BMP in memory and then past it to output:

    DeleteObject(hBMP);     // delete previous hBMP
    hBMP = CreateBitmap(Calculation.Width, Calculation.Height, 1, 32, IntPtr.Zero);
    SelectObject(hDC, hBMP);
    Calculation.G = Graphics.FromHdc(hDC);

    Calculation.G.Clear(Color.White);
    Calculation.DrawBMP(); // complex serie of DrawText, DrawLine etc.

    ...

    OutputGraphics.DrawImageUnscaled(Bitmap.FromHbitmap(hBMP), 0, 0);


The problem:
I can change position of any equation using NumericUpDown. It works perfectly for several times.
Than (totally randomly) just part of the calculation is printed - please see screenshots.
On next position change everything is OK again.

I use Graphics.DrawString, Graphics.DrawLine in Calculation.DrawBMP()

I appreciate any help!

Please see screenshots (change number of image):
http://arb-builder.cz/POM/1.jpg
to 
http://arb-builder.cz/POM/6.jpg
