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

MaskedTextBox Copy Paste

8 Answers 468 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Khizar Khan
Top achievements
Rank 1
Khizar Khan asked on 26 Jan 2011, 01:38 PM
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

8 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 26 Jan 2011, 06:40 PM
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
0
Khizar Khan
Top achievements
Rank 1
answered on 27 Jan 2011, 12:27 PM
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
0
Richard Slade
Top achievements
Rank 2
answered on 27 Jan 2011, 12:49 PM
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
0
Khizar Khan
Top achievements
Rank 1
answered on 27 Jan 2011, 01:12 PM
Hi,

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

Regards,
Khizar
0
Richard Slade
Top achievements
Rank 2
answered on 27 Jan 2011, 01:19 PM
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
0
Stefan
Telerik team
answered on 31 Jan 2011, 10:47 AM
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.
0
Khizar Khan
Top achievements
Rank 1
answered on 31 Jan 2011, 10:59 AM
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
0
Stefan
Telerik team
answered on 02 Feb 2011, 04:48 PM
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.
Tags
TextBox
Asked by
Khizar Khan
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Khizar Khan
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or