This is a migrated thread and some comments may be shown as answers.

Overtyping causes exception

4 Answers 67 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Andrew Knowles
Top achievements
Rank 1
Andrew Knowles asked on 27 Nov 2008, 05:15 PM
Hi,

I have a problem with the masked edit in Q2 2008 SP1

If I highlight all the text in the edit control, and then begin typing (so that the previous text is replaced) I get the following exception occurring on the Application.Run line of my application:


System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="Telerik.WinControls.UI"
  StackTrace:
       at Telerik.WinControls.UI.RadMaskTextBox.OnKeyDown(KeyEventArgs e)
       at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
       at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
       at System.Windows.Forms.Control.WmKeyChar(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
       at System.Windows.Forms.TextBox.WndProc(Message& m)
       at Telerik.WinControls.UI.HostedTextBoxBase.WndProc(Message& message)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at SewWhat_Database_Manager.Program.Main() in D:\Visual Studio 2005 Projects\Sewwhat\SewWhat Database Manager\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


This happens with several edits, some with masks, some without. If I delete the text in the box using backspace and then type everything is fine. I do not have any Keydown event handlers. Some of the edits have a handler for keypress, but this problem even occurs with those that do not.

Please help.
Since upgrading from the Q1 2008 to this version I have had nothing but problems in many of the controls.

Thankyou

4 Answers, 1 is accepted

Sort by
0
Andrew Knowles
Top achievements
Rank 1
answered on 27 Nov 2008, 06:00 PM
OK,

After eventually managing to compile the source code for the controls, the line causing the problem is Below in Bold
(From RadMaskTextBox.cs in Radcontrolsui\radmaskededitbox\ui\)

        protected override void OnKeyDown(KeyEventArgs e) 
        { 
            if (this.ReadOnly) 
            { 
                base.OnKeyDown(e); 
                return
            } 
 
            if (this.SelectionLength > 1) 
            { 
                int maskHandlerSelectionStart = this.maskHandler.SelectionStart; 
 
                if (maskHandler as RadStandardMaskHandler != null
                { 
                    while (base.SelectionStart < this.maskHandler.SelectionStart) 
                    { 
                        this.maskHandler.HandleLeftKey(); 
 
                        if (maskHandlerSelectionStart == this.maskHandler.SelectionStart) 
                            break
 
                        maskHandlerSelectionStart = this.maskHandler.SelectionStart; 
                    } 
                } 
            } 
 
            if (e.Handled) 
            { 
                return
            }  
            RadMaskEditBehavior.HandleKeyDown(e); 
            base.OnKeyDown(e); 
        } 
 

It crashes here, because maskhandler is null.

Is there a solution to this?

Thankyou.


0
Boyko Markov
Telerik team
answered on 28 Nov 2008, 05:15 PM
Hello Andrew Knowles,

Please, excuse us for the troubles the new version is causing. We understand how tedious this can be, so we have done our best to describe all breaking changes and how to fix them in the Release Notes. We will be glad to help you with any other issues you are facing.

As to the current problem with the masked box, could you please send me a very simple project demonstrating the issue? I have tested it locally and wasn't able to reproduce this problem. The maskhandler's instance shouldn't be null in any circumstances. What are the values of the maskType and Mask properties?

Note that I have moved your Forum post to the support ticketing system to allow attachments. The ticket id is 176833.

I'm looking forward to your reply.

Greetings,
Boyko Markov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dave
Top achievements
Rank 1
answered on 04 Feb 2009, 05:08 PM
I'm experiencing the exact same issue. Was there a resolution to this post? I'm using builed 2008.31321
Thanks,

Dave
0
Boyko Markov
Telerik team
answered on 05 Feb 2009, 01:31 PM
Hello Dave,

Thank you for contacting us.

The MaskType property should be set to Standard, DateTime or Numeric if you want the control to work with the Mask property, otherwise you will have the behavior of a simple TextBox control. In your case the mask type should be standard. Please set the MaskType property to Standard and the Mask type property to "000.000.000.000" for example.

We do not have a built in validation for IPs at the moment. However you can try to subscribe to the TextChanged, or ValueChanging and ValueChanged events of the control and modify the value as you wish.

Please contact me again if you have any other questions.
 
Kind regards,
Boyko Markov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
MaskedEditBox
Asked by
Andrew Knowles
Top achievements
Rank 1
Answers by
Andrew Knowles
Top achievements
Rank 1
Boyko Markov
Telerik team
Dave
Top achievements
Rank 1
Share this question
or