如何修复checkboxcombobox lastclosedtimestamp不起作用 [英] How do I fix checkboxcombobox lastclosedtimestamp not working

查看:84
本文介绍了如何修复checkboxcombobox lastclosedtimestamp不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TimeSpan TimeSpan = DateTime.Now.Subtract(dropDown.LastClosedTimeStamp);



parmp.popupComboBox.Items.Add(ALL);

parmp.popupComboBox.Visible = true;

parmp.popupComboBox.Show();



类型<的未处理异常br />
在CheckBoxComboBox.dll中发生'System.NullReferenceException'



每当我第一次点击新创建并显示的PopupComboBox时,我都会收到此错误。



看来由于某种原因,lastClosedTimeStamp从未被初始化,因为组件从未显示过,当我点击它时。它爆炸了。演示工作得很好,当我将CheckBoxComboBox文件夹添加到我的解决方案中然后将组件放在自定义控件(自​​定义控件包含一个面板,并在此面板的顶部,我放置CheckBoxComboBox)时自定义控件是创建并显示CheckBoxComboBox,我点击它然后我收到了这个错误。



请帮助。

谢谢,



我尝试了什么:



看来由于某种原因,lastClosedTimeStamp永远不会初始化,因为组件从未显示过,当我点击它时。它爆炸了。演示工作得很好,当我将CheckBoxComboBox文件夹添加到我的解决方案中然后将组件放在自定义控件(自​​定义控件包含一个面板,并在此面板的顶部,我放置CheckBoxComboBox)时自定义控件是创建并显示CheckBoxComboBox,我点击它然后我得到那个错误。

TimeSpan TimeSpan = DateTime.Now.Subtract( dropDown.LastClosedTimeStamp );

parmp.popupComboBox.Items.Add("ALL");
parmp.popupComboBox.Visible = true;
parmp.popupComboBox.Show();

An unhandled exception of type
'System.NullReferenceException' occurred in CheckBoxComboBox.dll

I get this error whenever I first click on a newly created and displayed PopupComboBox.

It appears that for some reason the lastClosedTimeStamp is never initialized because the component has never been shown, and when I click on it. It blows up. The Demo works well, it just does not work when I added the CheckBoxComboBox folder into my Solution and then place the component on inside a custom control (custom control contains a panel and on top of this panel I place the CheckBoxComboBox) when custom control is created and displaying the CheckBoxComboBox, I click on it then I get that error.

Please help.
Thank you,

What I have tried:

It appears that for some reason the lastClosedTimeStamp is never initialized because the component has never been shown, and when I click on it. It blows up. The Demo works well, it just does not work when I added the CheckBoxComboBox folder into my Solution and then place the component on inside a custom control (custom control contains a panel and on top of this panel I place the CheckBoxComboBox) when custom control is created and displaying the CheckBoxComboBox, I click on it then I get that error.

推荐答案

属性的名称表示它在控件关闭时返回日期时间最后一次。到目前为止还没有发生 null 。因此,您必须在代码中捕获该条件:

The name of the property indicates that it returns the datetime when the control has been closed the last time. It seems that null is returned when this has not happend so far. So you must catch that condition in your code:
// Use zero time span when dropDown does not exist or
//  dropDown.LastClosedTimeStamp not set.
TimeSpan span = new TimeSpan(0, 0, 0);
if (dropDown != null && dropDown.LastClosedTimeStamp != null)
    span = DateTime.Now.Subtract( dropDown.LastClosedTimeStamp );



之后检查此情况,然后您可以使用 TimeSpan.Zero 属性。


您需要联系制作您正在使用的控件的人并让他们修改修复此问题的源代码。
You need to contact whoever made the control you are using and have them modify the source code to fix this issue.


我通过在项目引用中包含对CheckBoxComboBox.dll的引用来解决问题,而不是将整个项目包含在解决方案中。修正了它。
I fixed the problem by including a reference to the CheckBoxComboBox.dll into my project references, instead of including the whole project into the solution. That fixed it.


这篇关于如何修复checkboxcombobox lastclosedtimestamp不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆