TreeView自行填充并崩溃Access

时间:2021-04-22 15:41:06

My problem is a tree view in my Access 2002 application.

我的问题是我的Access 2002应用程序中的树视图。

It is already populated, when I open the form. Which is strange, because the only code that adds the nodes is bound to a button.

当我打开表单时,它已经填充了。这很奇怪,因为添加节点的唯一代码绑定到一个按钮。

Also, only part of the data is shown and when I switch between tabs () the data inside the tree view duplicates/doubles. When I then hit any other tab Access crashes instantly just like * zap *

此外,仅显示部分数据,当我在tabs()之间切换时,树视图内的数据重复/加倍。当我然后点击任何其他选项卡Access时立即崩溃就像* zap *

Is it maybe necessary to clean a tree view all along?

是否可能需要一直清理树视图?

Any other ideas what the problem could be - solutions also welcome ;)

任何其他想法可能是什么问题 - 解决方案也欢迎;)

Cheers, Ramon

5 个解决方案

#1


I have come across this problem and traced it down to the treeview control does not like being on a tab page. You will have to redesign your form to keep the treeview outside the tab.

我遇到过这个问题,并将其追溯到树视图控件不喜欢在标签页上。您将不得不重新设计表单以将树视图保留在选项卡之外。

If it has to appear to be on a tab page then you could try .......

如果它必须显示在标签页上,那么你可以尝试.......

Placing the treeview behind the tab control. Setting the background of the tab control to transparant. On the "On Change" event of the tab control get it to check which tab is being selected. If it is the tab you want then set the treeview to visbale if not then hide it

将树视图放在选项卡控件后面。将选项卡控件的背景设置为transparant。在选项卡控件的“On Change”事件中,让它检查正在选择哪个选项卡。如果它是您想要的选项卡,则将树视图设置为visbale,如果不是,则将其隐藏

#2


I use a VCL (Delphi/BCB) wrapper as Tree View control on a tab (TTreeView on a TPageControl).

我在选项卡上使用VCL(Delphi / BCB)包装器作为树视图控件(TPageControl上的TTreeView)。

My program hangs once I call TreeView1.Items.Clear . But only in 'certain' cases! Especially if I expand an item and then try to Clear() all the items. If I never touch any node (or only scroll) it's fine.

一旦我调用TreeView1.Items.Clear,我的程序就会挂起。但只在“某些”情况下!特别是如果我展开一个项目然后尝试Clear()所有项目。如果我从不触摸任何节点(或只滚动),那就没关系。

I discovered that setting the selected node to NULL just before calling Items.Clear resolved it for me.

我发现在调用Items.Clear之前将所选节点设置为NULL为我解决了它。

Interestingly, calling Clear() caused a few OnChange events to occur for some reason, which was not expected (since we were deleting all the nodes anyway!)...

有趣的是,调用Clear()导致一些OnChange事件由于某种原因发生,这是不可能的(因为我们无论如何都要删除所有节点!)...

#3


First, find out why the TreeView is loading when you haven't told it to yet. Step through your code. You have to solve this first.

首先,找出为什么TreeView正在加载时尚未告诉它。逐步完成代码。你必须先解决这个问题。

Second, does the form crash if you don't load the TreeView but do switch Tabs?

其次,如果你没有加载TreeView但是切换Tabs,那么表单会崩溃吗?

#4


thank you for your suggestions.

谢谢你的建议。

I still did not found out why data is loaded into the TreeView, but I came up with a solution.

我仍然没有发现为什么数据被加载到TreeView中,但我想出了一个解决方案。

First I started to clean up the TreeView when the form is loaded.
That really did some good to stability. Now it is possible to click around without crashing Access.

首先,我在加载表单时开始清理TreeView。这确实对稳定有所帮助。现在可以在不崩溃Access的情况下单击。

When data is loaded to the TreeView the old behaviour shows up again. Switching between tabs adds more data and finally crashes Access.

当数据加载到TreeView时,旧的行为再次出现。在选项卡之间切换会添加更多数据并最终导致Access崩溃。

It seems like the TreeView (Version 6.0) is rebuilding itself without cleaning up properly.
Based on this assumption, I now clear and rebuild the TreeView when switching to the containing tab.

看起来TreeView(版本6.0)正在重建自己而没有正确清理。基于这个假设,我现在在切换到包含选项卡时清除并重建TreeView。

I am still interested in the root cause, but its working now.

我仍然对根本原因感兴趣,但它现在正在工作。

Thanks again, Ramon

再次感谢,拉蒙

#5


I can't believe this problem still persists and no fix was published by Microsoft! I have faced this same issue with Windows 8.1 running Office 2010

我无法相信这个问题仍然存在,微软也没有发布任何修复程序!我在运行Office 2010的Windows 8.1中遇到了同样的问题

In any case, the simplest workaround that I reached (and which probably saves resources) was to build the TreeView of the currently active tab in the form's "On Current Event".

在任何情况下,我达到的最简单的解决方法(可能节省资源)是在表单的“On Current Event”中构建当前活动选项卡的TreeView。

Private Sub Form_Current()
    Select Case Me.tabCompany.Value 'Return Page Index of active page
        Case 0  ' Page Index for Page 1.
            Call TVPage1
        Case 1  ' Page Index for Page 2.
            Call TVPage2
    End Select
End Sub

Another thing to keep in mind is to run the same routine to update the TreeView while switching from one page to another in "On Change Event" of the tab:

要记住的另一件事是运行相同的例程来更新TreeView,同时在选项卡的“On Change Event”中从一个页面切换到另一个页面:

Private Sub tabCompany_Change()
    Select Case Me.tabCompany.Value 'Return Page Index of active page
        Case 0  ' Page Index for Page 1.
            Call TVPage1
        Case 1  ' Page Index for Page 2.
            Call TVPage2
    End Select
End Sub

Cheers!

#1


I have come across this problem and traced it down to the treeview control does not like being on a tab page. You will have to redesign your form to keep the treeview outside the tab.

我遇到过这个问题,并将其追溯到树视图控件不喜欢在标签页上。您将不得不重新设计表单以将树视图保留在选项卡之外。

If it has to appear to be on a tab page then you could try .......

如果它必须显示在标签页上,那么你可以尝试.......

Placing the treeview behind the tab control. Setting the background of the tab control to transparant. On the "On Change" event of the tab control get it to check which tab is being selected. If it is the tab you want then set the treeview to visbale if not then hide it

将树视图放在选项卡控件后面。将选项卡控件的背景设置为transparant。在选项卡控件的“On Change”事件中,让它检查正在选择哪个选项卡。如果它是您想要的选项卡,则将树视图设置为visbale,如果不是,则将其隐藏

#2


I use a VCL (Delphi/BCB) wrapper as Tree View control on a tab (TTreeView on a TPageControl).

我在选项卡上使用VCL(Delphi / BCB)包装器作为树视图控件(TPageControl上的TTreeView)。

My program hangs once I call TreeView1.Items.Clear . But only in 'certain' cases! Especially if I expand an item and then try to Clear() all the items. If I never touch any node (or only scroll) it's fine.

一旦我调用TreeView1.Items.Clear,我的程序就会挂起。但只在“某些”情况下!特别是如果我展开一个项目然后尝试Clear()所有项目。如果我从不触摸任何节点(或只滚动),那就没关系。

I discovered that setting the selected node to NULL just before calling Items.Clear resolved it for me.

我发现在调用Items.Clear之前将所选节点设置为NULL为我解决了它。

Interestingly, calling Clear() caused a few OnChange events to occur for some reason, which was not expected (since we were deleting all the nodes anyway!)...

有趣的是,调用Clear()导致一些OnChange事件由于某种原因发生,这是不可能的(因为我们无论如何都要删除所有节点!)...

#3


First, find out why the TreeView is loading when you haven't told it to yet. Step through your code. You have to solve this first.

首先,找出为什么TreeView正在加载时尚未告诉它。逐步完成代码。你必须先解决这个问题。

Second, does the form crash if you don't load the TreeView but do switch Tabs?

其次,如果你没有加载TreeView但是切换Tabs,那么表单会崩溃吗?

#4


thank you for your suggestions.

谢谢你的建议。

I still did not found out why data is loaded into the TreeView, but I came up with a solution.

我仍然没有发现为什么数据被加载到TreeView中,但我想出了一个解决方案。

First I started to clean up the TreeView when the form is loaded.
That really did some good to stability. Now it is possible to click around without crashing Access.

首先,我在加载表单时开始清理TreeView。这确实对稳定有所帮助。现在可以在不崩溃Access的情况下单击。

When data is loaded to the TreeView the old behaviour shows up again. Switching between tabs adds more data and finally crashes Access.

当数据加载到TreeView时,旧的行为再次出现。在选项卡之间切换会添加更多数据并最终导致Access崩溃。

It seems like the TreeView (Version 6.0) is rebuilding itself without cleaning up properly.
Based on this assumption, I now clear and rebuild the TreeView when switching to the containing tab.

看起来TreeView(版本6.0)正在重建自己而没有正确清理。基于这个假设,我现在在切换到包含选项卡时清除并重建TreeView。

I am still interested in the root cause, but its working now.

我仍然对根本原因感兴趣,但它现在正在工作。

Thanks again, Ramon

再次感谢,拉蒙

#5


I can't believe this problem still persists and no fix was published by Microsoft! I have faced this same issue with Windows 8.1 running Office 2010

我无法相信这个问题仍然存在,微软也没有发布任何修复程序!我在运行Office 2010的Windows 8.1中遇到了同样的问题

In any case, the simplest workaround that I reached (and which probably saves resources) was to build the TreeView of the currently active tab in the form's "On Current Event".

在任何情况下,我达到的最简单的解决方法(可能节省资源)是在表单的“On Current Event”中构建当前活动选项卡的TreeView。

Private Sub Form_Current()
    Select Case Me.tabCompany.Value 'Return Page Index of active page
        Case 0  ' Page Index for Page 1.
            Call TVPage1
        Case 1  ' Page Index for Page 2.
            Call TVPage2
    End Select
End Sub

Another thing to keep in mind is to run the same routine to update the TreeView while switching from one page to another in "On Change Event" of the tab:

要记住的另一件事是运行相同的例程来更新TreeView,同时在选项卡的“On Change Event”中从一个页面切换到另一个页面:

Private Sub tabCompany_Change()
    Select Case Me.tabCompany.Value 'Return Page Index of active page
        Case 0  ' Page Index for Page 1.
            Call TVPage1
        Case 1  ' Page Index for Page 2.
            Call TVPage2
    End Select
End Sub

Cheers!