Invisible or disabled control cannot be activated
在WPF 应用程序下出现:Invisible or disabled control cannot be activated(不见的或禁用的控件不能被激活)错误。
System.ArgumentException: Invisible or disabled control cannot be activated
at System.Windows.Forms.ContainerControl.SetActiveControlInternal(Control value)
at System.Windows.Forms.ContainerControl.SetActiveControl(Control ctl)
at System.Windows.Forms.ContainerControl.set_ActiveControl(Control value)
at System.Windows.Forms.Integration.WindowsFormsHost.RestoreFocusedChild()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
解决办法:
该错误是线程的问题,对程序运行无影响,可以考虑过滤该错误。
方法如下:
1 确保删除的控件不是不见的或禁用的控件。
2 过滤该错误方法。
public MainWindow()
{
System.Windows.Forms.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
}
void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
if (!FailureFromFocusedChild(e.Exception))
{
System.Windows.Forms.Application.ThreadExceptionDialog dlg;
dlg = new System.Windows.Forms.Application.ThreadExceptionDialog(e.Exception);
dlg.ShowDialog();
}
private bool FailureFromFocusedChild(Exception e)
{
bool result = false;
string stackTrace = e.StackTrace;
result = (e is System.ArgumentException) && (e.Source == "System.Windows.Forms")
&& (stackTrace.IndexOf("System.Windows.Forms.Integration.WindowsFormsHost.RestoreFocusedChild")>=0);
return result;
}
参考:http://support.microsoft.com/kb/2686194
Invisible or disabled control cannot be activated的更多相关文章
- System and method for dynamically adjusting to CPU performance changes
FIELD OF THE INVENTION The present invention is related to computing systems, and more particularly ...
- IBM DB2 SQL error code list
SQL return codes that are preceded by a minus sign (-) indicate that the SQL statement execution was ...
- NoVNC API 文档翻译
原文地址:https://github.com/novnc/noVNC/blob/master/docs/API.md 时间:2019-05-21 noVNC API The interfac ...
- 计算机程序和C++语言简介
C++程序设计 第一章 计算机程序和C++语言简介 1.计算机是一台能够存储并处理数据的电子设备,包含硬件和软件两部分. 2.计算机硬件由: 1)中央处理单元(Central Processing U ...
- Windows 窗体中的事件顺序(WinForm)
引用MSDN,以便以后查看 引用:https://msdn.microsoft.com/zh-cn/library/86faxx0d.aspx 应用程序启动和关闭事件 Form 和 Control ...
- Windows 窗体中的事件顺序
来自:https://docs.microsoft.com/zh-cn/dotnet/framework/winforms/order-of-events-in-windows-forms 对于依次处 ...
- 修改文件夹的protection level之后,哪个job会来执行re-stripe的操作呢?
有下面的一些job可能参与其中的,他们的描述如下: AutoBalance,AutoBalanceLin - Balances free space in the cluster. The goal ...
- WinForm 生命周期, WinForm 事件执行顺序
1.窗体启动: Control.HandleCreatedControl.BindingContextChangedForm.LoadControl.VisibleChangedForm.Activa ...
- 让 Winform 窗口悬浮的简单方式
很多次设置这个 TopMost 属性会莫名的不起作用,有时又可以.一直在想是为什么会这样? 后来多次尝试,发现这个属性必须在窗体某些其他属性后设置,比如在 Height.Width 这样的属性后. 看 ...
随机推荐
- Java魔法堂:以Windows服务的形式运行Java程序
一.前言 由于防止维护人员误操作关闭Java控制台程序,因此决定将其改造为以Windows服务的形式运行.弄了一个上午总算搞定了,下面记录下来,以供日后查阅. 二.Java Service Wrapp ...
- CentOS6.5菜鸟之旅:安装输入法(小呀小企鹅)
一.前言 假如在登录系统的时候语言选择了中文,那么是系统会自带ibus的中文输入法.但由于我打算用英文版,于是就被小企鹅输入法(FCITX)折腾了两个晚上. 二.检查系统编码 在bash中输入 loc ...
- python学习笔记 - 初识socket
socket socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求. sock ...
- ASP.NET 使用AJAX让GridView的数据行显示提示框(ToolTip)
介绍ASP.NET AJAX可以使你的web应用程序具有更丰富的功能和更多的用户响应. 本文中,我将演示如何通过ASP.NET AJAX的帮助,给像GridView这样的数据绑定控件的数据行增加pop ...
- ASP.NET或WinFrom中获取汉子的拼音首字母
1.获得一个字符串的每个字的拼音首字母构成所需的字符串 #region 获取首字母 /// <summary> /// 这个办法是用来获得一个字符串的每个字的拼音首字母构 ...
- csharp: Sound recording
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsof ...
- sql多行转一行,以逗号隔开
--SELECT ff= stuff((select ','+cast(WorkOrderNo as varchar)-- FROM dbo.TB_WorkOrder c -- where tpl.P ...
- hibernate3 Duplicate class/entity mapping(异常)
hibernate3 Duplicate class/entity mapping(异常) 代码: Configuration config = new Configuration().ad ...
- Hibernate关联映射及高级查询
一.Hibernate中的关联关系 1.1.单向一对多关联关系 按照以下步骤配置hibernate中持久化类的一对多对象关联: (1).持久化类添加关联类的相关属性及getter/setter方法. ...
- C#枚举类型和结构体
注意:枚举类型和结构体都属于值类型. 结构体:就是一个自定义的集合,里面可以放各种类型的元素,用法大体跟集合一样. 一.定义的方法: struct student { public int nianl ...