title: exception while sorting data grid column "Object must be of type Double." after changing the value
body: <p>I've a data grid <code>gridDetails</code> with columns <code>discount</code> and <code>total</code> filled from the database</p>
  
  <p><code>Total</code> is readonly while <code>discount</code> is not. When the value of discount is changed, The total is recalculated as</p>
  
  <pre><code>gridDetails.Item(1, e.RowIndex).Value -= (Val(gridDetails.Item(2, e.RowIndex).Value))
  </code></pre>
  
  <p>after changing the value the column cant be sorted. it generates an exception </p>
  
  <pre><code>System.ArgumentException was unhandled
    Message="Object must be of type Double."
    Source="mscorlib"
    StackTrace:
         at System.Double.CompareTo(Object value)
         at System.Collections.Comparer.Compare(Object a, Object b)
         at System.Windows.Forms.DataGridViewRowCollection.RowComparer.CompareObjects(Object value1, Object value2, Int32 rowIndex1, Int32 rowIndex2)
         at System.Windows.Forms.DataGridViewRowCollection.RowArrayList.Pivot(Int32 left, Int32 center, Int32 right)
         at System.Windows.Forms.DataGridViewRowCollection.RowArrayList.CustomQuickSort(Int32 left, Int32 right)
         at System.Windows.Forms.DataGridViewRowCollection.RowArrayList.CustomSort(RowComparer rowComparer)
         at System.Windows.Forms.DataGridViewRowCollection.Sort(IComparer customComparer, Boolean ascending)
         at System.Windows.Forms.DataGridView.SortInternal(IComparer comparer, DataGridViewColumn dataGridViewColumn, ListSortDirection direction)
         at System.Windows.Forms.DataGridView.Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction)
         at System.Windows.Forms.DataGridView.OnColumnHeaderMouseClick(DataGridViewCellMouseEventArgs e)
         at System.Windows.Forms.DataGridView.OnMouseClick(MouseEventArgs e)
         at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
         at System.Windows.Forms.Control.WndProc(Message&amp; m)
         at System.Windows.Forms.DataGridView.WndProc(Message&amp; m)
         at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
         at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
         at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
         at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; 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(ApplicationContext context)
         at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
         at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
         at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
         at cableguy.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
         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()
    InnerException:
  </code></pre>
  
  <p>i've converted the result to double using Cdbl, DirectCast etc.. no hope
  like 
  <code>gridDetails.Item(1, e.RowIndex).Value = Cdbl(gridDetails.Item(1, e.RowIndex).Value-Val(gridDetails.Item(2, e.RowIndex).Value))</code></p>
  
  <p>any idea??</p>