我的Windows窗体应用程序中有一个Telerik Tabbed PageView,我可以通过双击它们来编辑标签的标题,从而启动文本编辑器。以下潜艇负责更改标签 - 检查编辑的标签是否为空白:
Private Sub ViewElement_EditorInitialized(sender As Object, e As UI.RadPageViewEditorEventArgs)
AddHandler MountingSystemTabControl.ViewElement.ActiveEditor.Validating, AddressOf ActiveEditor_Validating
AddHandler MountingSystemTabControl.ViewElement.ActiveEditor.Validated, AddressOf ActiveEditor_Validated
AddHandler MountingSystemTabControl.ViewElement.ActiveEditor.ValidationError, AddressOf ActiveEditor_ValidationError
End Sub
Private Sub ActiveEditor_Validating(sender As Object, e As CancelEventArgs)
Dim editor As UI.RadPageViewElement.PageViewItemTextEditor = TryCast(sender, UI.RadPageViewElement.PageViewItemTextEditor)
If editor IsNot Nothing AndAlso MountingSystemTabControl.ViewElement.ActiveEditor.Value = String.Empty Then
e.Cancel = True
End If
End Sub
Private Sub ActiveEditor_ValidationError(sender As Object, e As UI.ValidationErrorEventArgs)
RadMessageBox.Show("Array label can't be empty!", "Error", MessageBoxButtons.OK, RadMessageIcon.[Error])
End Sub
Private Sub ActiveEditor_Validated(sender As Object, e As EventArgs)
RadMessageBox.Show("Array label has been successfully updated!", "Information", MessageBoxButtons.OK, RadMessageIcon.Info)
End Sub
此外,我的Form_Load事件中有这一行:
AddHandler MountingSystemTabControl.ViewElement.EditorInitialized, AddressOf ViewElement_EditorInitialized
现在问题是,每当我运行代码时,在MessageBox向我显示" 数组标签已成功更新后!"消息,抛出 NullReference异常,似乎即使使用应用程序事件处理程序也无法捕获它!破解代码后,Visual Studio将此行作为异常来源引用我:
RadMessageBox.Show("Array label has been successfully updated!", "Information", MessageBoxButtons.OK, RadMessageIcon.Info)
这让我感到困惑,因为我无法找到该行中的任何内容(当然有些东西,但我不知道是什么)。
答案 0 :(得分:0)
由于内存服务......我认为RadMessageBox会调用Parent参数。
试试这个:
RadMessageBox.Show(Me, "Array label has been successfully updated!", "Information", MessageBoxButtons.OK, RadMessageIcon.Info)
答案 1 :(得分:0)
通过更新到2015年WinForms的Telerik UI(版本 2015.1.225 )'
解决了该问题