hey guys,
was having a great time with SkyBound's FreeStyle when i ran into a very funny problem. On removing a tabpage from the tabcontrol which is using the FreeStyle component, i get an error when executing the following line:
this.Controls.Remove(this.TabPages[SelectedIndex]);
exception thrown is:
System.ArgumentOutOfRangeException was unhandled
Message="InvalidArgument=Value of '0' is not valid for 'index'.\r\nParameter name: index"
Source="System.Windows.Forms"
ParamName="index"
StackTrace:
at System.Windows.Forms.TabControl.GetTabRect(Int32 index)
at xd7781b9627ed1947.x86e4a8bb25bfd380.xb821f4eb74ae7ed5(TabControl x43f09fa35b632ec6, Int32 xc0c4c459c6ccbd00)
at xd7781b9627ed1947.x86e4a8bb25bfd380.xd727d28790d9fe4e(Message& x6088325dec1baa2a)
at xd7781b9627ed1947.x8ec6a1317a73ae90.xf43577d7fc7fb2d4(IntPtr x96e7d32425e52ebf, Int32 x8a41fbc87a3fb305, IntPtr x716e0bc3eafdded2, IntPtr x130fbcecf32fe781)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at testing.Program.Main() in C:\Documents and Settings\lauchunghan\My Documents\Visual Studio 2005\Projects\testing\testing\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
however, if i slightly modify the above code to include a messagebox, everything works fine!
if (MessageBox.Show("Close?", "Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.Controls.Remove(this.TabPages[SelectedIndex]);
}
i really can't figure out what is wrong.
regards.