MaskedTextBox Copy Paste

9 posts, 0 answers
  1. Khizar Khan
    Khizar Khan avatar
    41 posts
    Member since:
    Jan 2010

    Posted 26 Jan 2011 Link to this post

    Hi,

    I think there is a possible bug in MasktedTextBox when you copy paste. here is the scenario to recreate this.

    have a MaskedTextBox with masktext as 00-00-00 (Sort Code) with Type as Standard.

    run the application and you will see the text is now defaulted to 00-00-00.

    1. Open notepad and type 222222 (6 chars) and select the text and right click and copy.
    2. block/Select all the maskedtext in the app,
    3. right click and select paste option.
    4. you will see the text pasted in the masked textbox and
    5. Tabout using a tab key and the copied text disappears.. and defaults to 00-00-00. where as the values should have been 22-22-22.

    Note: this doesn't occur when you do ctrl+v and if you do ctrl+v first time then right click option works fine here after.

    please advice.

    Regards,
    Khizar
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 26 Jan 2011 Link to this post

    Hello,

    Please have a look at my answers in this forum thread that will assistn you in addressing the copy and paste issue that you are experiencing.

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Khizar Khan
    Khizar Khan avatar
    41 posts
    Member since:
    Jan 2010

    Posted 27 Jan 2011 Link to this post

    Hi,
    My problem is not with Ctrl + C  and  Ctrl + V. this works perfectly fine.
    it is the problem when you do it with the windows context menu (right click on the maskedtextbox)  and select paste for the first time and tab out without CtrlV

    Hope this helps.

    Regards,
    Khizar
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    Hello,

    Apologies, please can you try this..

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler Me.RadMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.TextChanged, AddressOf MaskedEdit_TextChanged
    End Sub
    Private Sub MaskedEdit_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
        If Not Me.RadMaskedEditBox1.Text.Contains("-") Then
            Me.RadMaskedEditBox1.Value = Clipboard.GetText()
        End If
    End Sub

    Let me know if that helps
    Richard
  6. Khizar Khan
    Khizar Khan avatar
    41 posts
    Member since:
    Jan 2010

    Posted 27 Jan 2011 Link to this post

    Hi,

    Thanks, can you please give teh above code in c#

    Regards,
    Khizar
  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    Hello,

    No problem, here is the same code in C#

    public Form1()
    {
        InitializeComponent();
        this.Load += new System.EventHandler(this.Form1_Load);
    }
    private void Form1_Load(object sender, EventArgs e)
    {
        this.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem.TextChanged += new System.EventHandler(this.MaskedEdit_TextChanged);
    }
    private void MaskedEdit_TextChanged(Object sender, EventArgs e)
        if (! this.radMaskedEditBox1.Text.Contains("-"))
        {
            this.radMaskedEditBox1.Value = Clipboard.GetText();
        }
    }

    Hope that helps
    Richard
  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 31 Jan 2011 Link to this post

    Hi Khizar Khan,

    Thank you for writing.

    Let me know if the provided solution works for you or if you need further assistance.

    Richard, thank you for the community effort.
     
    Greetings,
    Stefan
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  9. Khizar Khan
    Khizar Khan avatar
    41 posts
    Member since:
    Jan 2010

    Posted 31 Jan 2011 Link to this post

    Hello,

    Sorry for delay in response.

    Yes it worked.. looking forward this to be fixed in your future releases.
    thanks for your help.

    Regards,
    Khizar
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Feb 2011 Link to this post

    Hello Khizar Khan,

    Thank you for the clarification. Here is a link to the PITS issue (Public Issue Tracking System), in case that you want to receive a notification when its status is changed.
     
    I have updated your Telerik points as a token of our gratitude. 

    Kind regards,
    Stefan
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Back to Top
UI for WinForms is Visual Studio 2017 Ready