ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2016-02-27 07:37:52

maibo
Member
Registered: 2016-01-27
Posts: 15

Worksheet 不能Dispose

private void Button_Click(object sender, RoutedEventArgs e)
        {
            var grid = windowsFormsHost.Child as unvell.ReoGrid.ReoGridControl;
var sheet = grid.CurrentWorksheet;
            sheet.Dispose();
运行后的出错信息如下:
未处理System.ArgumentOutOfRangeException
  HResult=-2146233086
  Message=索引超出范围。必须为非负值并小于集合大小。
参数名: index
  Source=mscorlib
  ParamName=index
  StackTrace:
       在 System.Collections.Generic.List`1.get_Item(Int32 index)
       在 unvell.ReoGrid.Worksheet.GetRangePhysicsBounds(RangePosition range)
       在 bj.OnMouseMove(Point location, MouseButtons buttons)
       在 eb.OnMouseMove(Point location, MouseButtons buttons)
       在 unvell.ReoGrid.ReoGridControl.b(PointF A_0, MouseButtons A_1)
       在 unvell.ReoGrid.ReoGridControl.OnMouseMove(MouseEventArgs e)
       在 System.Windows.Forms.Control.WmMouseMove(Message& m)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 unvell.ReoGrid.ReoGridControl.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       在 System.Windows.Application.RunInternal(Window window)
       在 System.Windows.Application.Run()
       在 WpfApplication2.App.Main() 位置 i:\ReoGrid-1.1.0-All-Packages\WpfApplication1\WpfApplication2\obj\Debug\App.g.cs:行号 0
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Last edited by maibo (2016-02-27 07:39:47)

Offline

#2 2016-02-27 10:32:13

oops
Moderator
Registered: 2015-11-03
Posts: 54

Re: Worksheet 不能Dispose

设置为 CurrentWorksheet 的 Worksheet 不能被 Dispose,现在的版本没有检查这个条件。
另外被追加到 Workbook 里的 Worksheet 也不能 Dispose,下个版本将加入检查条件。

只有被创建出来还未加入 Workbook 的 Worksheet 和已经从 Workbook 中移除的 Worksheet 可以被 Dispose。

如果想重置 CurrentWorksheet,可以使用 Reset 方法。

var sheet = grid.CurrentWorksheet;
sheet.Reset();

Offline

#3 2016-02-27 12:01:16

maibo
Member
Registered: 2016-01-27
Posts: 15

Re: Worksheet 不能Dispose

明白,谢谢。

Offline

Board footer

Powered by FluxBB