C# Exception Problem

hello, i am designing a form with a datagridview and assigning different fonts in all the cells. the prob is ArgumentException is thrown at random times when sLang.ShowDialog(). when the form is open.

designer, code , resx file and "font folder" included:>
Free File Hosting & Video Downloads, Free File Sharing, Online Friends Network - Ziddu

(note:change the namespace)
it will require 19 or less fonts named 0.ttf, 1.ttf..........in "C:\fonts\"

if any questions abt coding pl ask. any suggestion is welcome
 
found the problem :

Code:
public Bitmap ConvertTextToBitmap(int width, int height, string str, Font fontName)
        {
            using (Bitmap bmp = new Bitmap(width, height))
            {
                using (Graphics gfx = Graphics.FromImage((Image)bmp))
                {
                    gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    Font font = fontName;
                    gfx.FillRectangle(Brushes.Transparent, new Rectangle(0, 0, bmp.Width, bmp.Height));
                    gfx.FillRectangle(Brushes.White, 0, 0, width, height);
                    gfx.DrawString(str, font, new SolidBrush(Color.Black), 2, 3);
                    return bmp;
                }
            }
        }

looks like the returned bitmap is corrupted all values throw exception.

didnt knew that would happen. any explanation ???????
 
Top Bottom