locked
ButtonRenderer Parameter is not valid RRS feed

  • Question

  • Hello all,

    My code is giving "Parameter is not valid" error to a few -- but not all -- customers.  The computers are Windows XP Pro, and everything works fine when they click "Continue".  Based on their description and the Exception Text (following) I believe the error to be in this code:

            void trvCriteria_DrawNode(object sender, DrawTreeNodeEventArgs e)
            {
                if (e.Node.Text.Trim() == MyProg.Properties.Resources.Custom)
                {
    
                    Font fnt = new Font("Arial", 7, System.Drawing.FontStyle.Italic);
    
                    ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.Node.Text, fnt, false, PushButtonState.Default);
    
                }
                else
    
                    e.DrawDefault = true;
    
            }

    ************** Exception Text **************

    System.ArgumentException: Parameter is not valid.

       at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)

       at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)

       at System.Windows.Forms.ControlPaint.DrawFrameControl(Graphics graphics, Int32 x, Int32 y, Int32 width, Int32 height, Int32 kind, Int32 state, Color foreColor, Color backColor)

       at System.Windows.Forms.ControlPaint.DrawButton(Graphics graphics, Int32 x, Int32 y, Int32 width, Int32 height, ButtonState state)

       at System.Windows.Forms.ControlPaint.DrawButton(Graphics graphics, Rectangle rectangle, ButtonState state)

       at System.Windows.Forms.ButtonRenderer.DrawButton(Graphics g, Rectangle bounds, String buttonText, Font font, TextFormatFlags flags, Boolean focused, PushButtonState state)

       at AccuPoint_3.Form1.trvCriteria_DrawNode(Object sender, DrawTreeNodeEventArgs e)

       at System.Windows.Forms.TreeView.OnDrawNode(DrawTreeNodeEventArgs e)

       at System.Windows.Forms.TreeView.CustomDraw(Message& m)

       at System.Windows.Forms.TreeView.WmNotify(Message& m)

       at System.Windows.Forms.TreeView.WndProc(Message& m)

       at AccuPoint_3.MixedCheckBoxesTreeView.WndProc(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    I already asked if Arial Italic is installed, and I could not reproduce the error by removing the font from my computer.  Any ideas?

    Thanks in advance.


    • Edited by trufaux Friday, April 20, 2012 2:39 PM
    Thursday, April 19, 2012 3:15 PM

Answers

All replies