NumericUpDown in DataGridView in VS.Net 2005 BETA

G

Guest

I used the article located at
ms-help://MS.VSCC.v80/MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxmclictl/html/e79a9d4e-64ec-41f5-93ec-f5492633cbb2.htm
to create a custom numeric updown control to host it in a datagridview. The
code for the control is attached in the .cs file.

It is working, mostly… when I change the value of the cell using the numeric
keypad and change rows I don’t have a problem but when I change the value of
the cell using the numeric up down control then I get the following error.

“Specified cast is not valid.â€

This is the stacktrace.
" at System.Windows.Forms.DataGridView.EditingControls_Click(Object
sender, EventArgs e)\r\n at System.Windows.Forms.Control.OnClick(EventArgs
e)\r\n at System.Windows.Forms.UpDownButtons.OnMouseUp(MouseEventArgs
e)\r\n at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)\r\n at System.Windows.Forms.Control.WndProc(Message&
m)\r\n at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&
m)\r\n at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)\r\n
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)\r\n at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at
System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason,
ApplicationContext context)\r\n at
System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)\r\n at
System.Windows.Forms.Application.Run(Form mainForm)\r\n at
IMax.Max.MaxApplication.Program.Main() in C:\\Work\\Max\\Max\\Program.cs:line
42\r\n at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)\r\n at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)\r\n at
VSHostUtil.HostProc.RunUsersAssembly()\r\n at
System.Threading._Thread.ThreadStart_Context(Object state)\r\n at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callBack, Object state, StackCrawlMark& stackMark)\r\n at
System.Threading._Thread.ThreadStart()"

Target Site: {Void EditingControls_Click(System.Object, System.EventArgs)}

I am not sure why the error is happening. I stepped through the code and
can’t really come to a conclusion.

Any help would be appreciated.
 
E

Ed Kaim

Although I don't have much context, I've noticed that I end up getting a lot
of headaches from the fact that NumericUpDowns use decimal types, which I
often forget when moving numbers around. It may or may not have to do with
the cast error.

kapilp said:
I used the article located at
ms-help://MS.VSCC.v80/MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxmclictl/html/e79a9d4e-64ec-41f5-93ec-f5492633cbb2.htm
to create a custom numeric updown control to host it in a datagridview.
The
code for the control is attached in the .cs file.

It is working, mostly. when I change the value of the cell using the
numeric
keypad and change rows I don't have a problem but when I change the value
of
the cell using the numeric up down control then I get the following error.

"Specified cast is not valid."

This is the stacktrace.
" at System.Windows.Forms.DataGridView.EditingControls_Click(Object
sender, EventArgs e)\r\n at
System.Windows.Forms.Control.OnClick(EventArgs
e)\r\n at System.Windows.Forms.UpDownButtons.OnMouseUp(MouseEventArgs
e)\r\n at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons
button, Int32 clicks)\r\n at
System.Windows.Forms.Control.WndProc(Message&
m)\r\n at System.Windows.Forms.ControlNativeWindow.OnMessage(Message&
m)\r\n at System.Windows.Forms.ControlNativeWindow.WndProc(Message&
m)\r\n
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)\r\n at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n
at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at
System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason,
ApplicationContext context)\r\n at
System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)\r\n at
System.Windows.Forms.Application.Run(Form mainForm)\r\n at
IMax.Max.MaxApplication.Program.Main() in
C:\\Work\\Max\\Max\\Program.cs:line
42\r\n at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)\r\n at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence
assemblySecurity, String[] args)\r\n at
VSHostUtil.HostProc.RunUsersAssembly()\r\n at
System.Threading._Thread.ThreadStart_Context(Object state)\r\n at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callBack, Object state, StackCrawlMark& stackMark)\r\n
at
System.Threading._Thread.ThreadStart()"

Target Site: {Void EditingControls_Click(System.Object, System.EventArgs)}

I am not sure why the error is happening. I stepped through the code and
can't really come to a conclusion.

Any help would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top