Monday, May 30, 2011

Flicker free controls: SplitContainer

.Net Flicker Fee Controls 


Here are the steps to use this control:
1. Add new class "NonFlickerSplitContainer" to your C# application.
2. Replace auto generated class code with C# code shown below.
3. Use NonFlickerSplitContainer object instead of SplitContainer object in your application.

    public partial class NonFlickerSplitContainer : SplitContainer
    {
        public NonFlickerSplitContainer()
        {
            this.SetStyle(ControlStyles.AllPaintingInWmPaint |
                               ControlStyles.UserPaint |
                               ControlStyles.OptimizedDoubleBuffer, true);

            MethodInfo objMethodInfo = typeof(Control).GetMethod(             "SetStyle",BindingFlags.NonPublic|BindingFlags.Instance);

            object[] objArgs = new object[] { ControlStyles.AllPaintingInWmPaint |
                                                                ControlStyles.UserPaint |
                                                               ControlStyles.OptimizedDoubleBuffer, true };

            objMethodInfo.Invoke(this.Panel1, objArgs);
            objMethodInfo.Invoke(this.Panel2, objArgs);
        }
    }

Flicker free controls: ListView

.Net Flicker Fee Controls 


Here are the steps to use this control:
1. Add new class "NonFlickerListView" to your C# application.
2. Replace auto generated class code with C# code shown below.
3. Use NonFlickerListView object instead of ListView object in your application.
   
public partial class NonFlickerListView : ListView
    {
        public NonFlickerListView()
        {
            this.GetType().GetProperty("DoubleBuffered",
System.Reflection.BindingFlags.NonPublic |                                                      System.Reflection.BindingFlags.Instance
).SetValue(this, true, null);
        }

            protected override void WndProc(ref Message messg)
        {
            if ((int)0x0014 == messg.Msg) // if message is is erase background
            {
                messg.Msg = (int)0x0000; // reset message to null
                return;
            }
            base.WndProc(ref messg);

        }
    }

Friday, May 27, 2011

Flicker free controls: GroupBox

.Net Flicker Fee Controls

Here are the steps to use this control:
1. Add new class "NonFlickerGroupBox" to your C# application.
2. Replace autogenerated class code with C# code shown below.
3. Use NonFlickerGroupBox object instead of GroupBox object in your application.

public partial class NonFlickerGroupBox : GroupBox
{
        public NonFlickerGroupBox() : base()
       {
                   this.SetStyle(ControlStyles.AllPaintingInWmPaint,
                                       ControlStyles.UserPaint
                                       ControlStyles.OptimizedDoubleBuffer,
                                       true);
       }
}

Fell free to post any query.

Flicker free controls: Panel

.Net Flicker Fee Controls
In first post Iam gonna post code of Filcker free Panel control. You can use this control in your application.

Here are the steps to use this control:
1. Add new class "NonFlickerPanel" to your C# application.
2. Replace autogenerated class code with C# code shown below.
3. Use NonFlickerPanel object instead of Panel object in your application.

public partial class NonFlickerPanel : Panel
{
       public NonFlickerPanel() : base()
       {
              this.SetStyle(ControlStyles.AllPaintingInWmPaint,
                                  ControlStyles.UserPaint
                                  ControlStyles.OptimizedDoubleBuffer,
                                  true);
       }
}
 
Fell free to post any query.

Sunday, March 13, 2011

Unhandled exception: input string was not in a correct format

Problem:
Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.

Cause:
This problem occurs if the value of the following registry key is not empty or is set to an invalid value:
HKEY_CURRENT_USER\Control Panel\International\sPositiveSign
Here are steps to fix this problem:
1. Open registry editor. 
2. Go to: HKEY_CURRENT_USER\Control Panel\International
3. Select: sPositiveSign
4. Right Click (sPositiveSign) >> Click Modify Binary Data >> Add two pair of 2 zero’s in Value Data box as shown below >> Click OK.


Sunday, March 6, 2011

Breakpoints are not hit when debugging in Visual Studio 2010


You may not be able to debug Excel Add-In with VS2010. Here are details of this problem and steps to fix the same.

Problem:        
Excel Add-In b breakpoints are not hit when debugging in Visual Studio 2010

Reason:
This problem occurs when you debug an add-in project targeting to .NET Framework 2.0-3.5 in VS 2010. The reason is the debugger, which doesn't know what .NET Framework version your add-in uses.
To find out that info, the debugger checks the .config file of the executable, which is the host application in your case. The examples of configuration file names are outlook.exe.config and excel.exe.config; if such a file exists, it is located in the Office folder; say, for Office 2007, the folder is C:\Program Files\Microsoft Office\OFFICE12. If the .config file is missing or it doesn't point to a specific .NET Framework version, the debugger uses the debugging engine of .NET Framework 4.0.

Solution:
To help the debugger, you can create (or modify) the .config file(s) for the Office application(s) installed on your PC.

Create a Excel.exe.config file with following content. 


<xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

You just need to place this file in Office folder (C:\Program Files\Microsoft Office\OFFICE12).