Hello to all!
I've a GridViewMaskBoxColumn, where float are displayed using the exponental notation. When I try to change a cells value, I can put the wished values, but when I leave the editor, the application crashs (even if I put only a '0')
The crash happens immediately after leaving the 'CellEndEdit'.
What went wrong in my source?
Thanks for your help!
System.NullReferenceException wurde nicht behandelt.
Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
Source=Telerik.WinControls.UI
StackTrace:
bei Telerik.WinControls.UI.RegexMaskTextBoxProvider.KeyDown(Object sender, KeyEventArgs e)
bei Telerik.WinControls.UI.RadMaskedEditBoxElement.TextBoxItem_KeyDown(Object sender, KeyEventArgs e)
bei System.Windows.Forms.KeyEventHandler.Invoke(Object sender, KeyEventArgs e)
bei Telerik.WinControls.RadItem.OnKeyDown(KeyEventArgs e)
bei Telerik.WinControls.UI.RadTextBoxItem.TextBoxControl_KeyDown(Object sender, KeyEventArgs e)
bei System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
bei System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
bei System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
bei System.Windows.Forms.Control.WmKeyChar(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.TextBoxBase.WndProc(Message& m)
bei System.Windows.Forms.TextBox.WndProc(Message& m)
bei Telerik.WinControls.UI.HostedTextBoxBase.WndProc(Message& message)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei Maxsyma.PLCExplorer.Program.Main() in e:\...\SourceCode\Regex\Program.cs:Zeile 40.
InnerException:
Here is my code:
private void InitializeGrid()
{
..
newColumn = new GridViewMaskBoxColumn(); // for float
newColumn.Name = "Gleitpunkt";
newColumn.TextAlignment = ContentAlignment.MiddleRight;
newColumn.Width = 60;
newColumn.HeaderText = "Gleitpunkt";
newColumn.FormatString = "{0:0.000000e0}";
this.radGridViewCapture.Columns.Add(newColumn);
..
}
private void CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
if (this.radGridViewCapture.ActiveEditor is RadMaskedEditBoxEditor)
{
RadMaskedEditBoxEditor spinEditor = this.radGridViewCapture.ActiveEditor as RadMaskedEditBoxEditor;
spinEditor.EditorElement.Alignment = ContentAlignment.MiddleCenter;
spinEditor.EditorElement.StretchVertically = false;
this.radGridViewCapture.CurrentCell.Alignment = ContentAlignment.MiddleCenter;
}
}
private void CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
if (this.radGridViewCapture.ActiveEditor is RadMaskedEditBoxEditor)
{
RadMaskedEditBoxEditor spinEditor = this.radGridViewCapture.ActiveEditor as RadMaskedEditBoxEditor;
if (e.Column.Name == ColumnName.Names[ColumnName.ResultGleitpunkt])
{
spinEditor.MaskTextBox.MaskType = MaskType.Regex;
spinEditor.MaskTextBox.Mask = "[-+]?([0-9]*[,.])?[0-9]+([eE][-+]?[0-9]+)?"; // e.g. 123.4e+5
}
}
}
private void CellEndEdit(object sender, GridViewCellEventArgs e)
{
if (e.Column.Name == "Gleitpunkt")
{
float myNewValue = float.Parse(e.Row.Cells[e.ColumnIndex].Value.ToString());
// myNewValue is e.g. 0 or 123 or 123.4e-88 and is correct so far
}
}
I've a GridViewMaskBoxColumn, where float are displayed using the exponental notation. When I try to change a cells value, I can put the wished values, but when I leave the editor, the application crashs (even if I put only a '0')
The crash happens immediately after leaving the 'CellEndEdit'.
What went wrong in my source?
Thanks for your help!
System.NullReferenceException wurde nicht behandelt.
Message=Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
Source=Telerik.WinControls.UI
StackTrace:
bei Telerik.WinControls.UI.RegexMaskTextBoxProvider.KeyDown(Object sender, KeyEventArgs e)
bei Telerik.WinControls.UI.RadMaskedEditBoxElement.TextBoxItem_KeyDown(Object sender, KeyEventArgs e)
bei System.Windows.Forms.KeyEventHandler.Invoke(Object sender, KeyEventArgs e)
bei Telerik.WinControls.RadItem.OnKeyDown(KeyEventArgs e)
bei Telerik.WinControls.UI.RadTextBoxItem.TextBoxControl_KeyDown(Object sender, KeyEventArgs e)
bei System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
bei System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
bei System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
bei System.Windows.Forms.Control.WmKeyChar(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.TextBoxBase.WndProc(Message& m)
bei System.Windows.Forms.TextBox.WndProc(Message& m)
bei Telerik.WinControls.UI.HostedTextBoxBase.WndProc(Message& message)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei Maxsyma.PLCExplorer.Program.Main() in e:\...\SourceCode\Regex\Program.cs:Zeile 40.
InnerException:
Here is my code:
private void InitializeGrid()
{
..
newColumn = new GridViewMaskBoxColumn(); // for float
newColumn.Name = "Gleitpunkt";
newColumn.TextAlignment = ContentAlignment.MiddleRight;
newColumn.Width = 60;
newColumn.HeaderText = "Gleitpunkt";
newColumn.FormatString = "{0:0.000000e0}";
this.radGridViewCapture.Columns.Add(newColumn);
..
}
private void CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
if (this.radGridViewCapture.ActiveEditor is RadMaskedEditBoxEditor)
{
RadMaskedEditBoxEditor spinEditor = this.radGridViewCapture.ActiveEditor as RadMaskedEditBoxEditor;
spinEditor.EditorElement.Alignment = ContentAlignment.MiddleCenter;
spinEditor.EditorElement.StretchVertically = false;
this.radGridViewCapture.CurrentCell.Alignment = ContentAlignment.MiddleCenter;
}
}
private void CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
if (this.radGridViewCapture.ActiveEditor is RadMaskedEditBoxEditor)
{
RadMaskedEditBoxEditor spinEditor = this.radGridViewCapture.ActiveEditor as RadMaskedEditBoxEditor;
if (e.Column.Name == ColumnName.Names[ColumnName.ResultGleitpunkt])
{
spinEditor.MaskTextBox.MaskType = MaskType.Regex;
spinEditor.MaskTextBox.Mask = "[-+]?([0-9]*[,.])?[0-9]+([eE][-+]?[0-9]+)?"; // e.g. 123.4e+5
}
}
}
private void CellEndEdit(object sender, GridViewCellEventArgs e)
{
if (e.Column.Name == "Gleitpunkt")
{
float myNewValue = float.Parse(e.Row.Cells[e.ColumnIndex].Value.ToString());
// myNewValue is e.g. 0 or 123 or 123.4e-88 and is correct so far
}
}