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

Masked Edit Box validation with Regex

8 Answers 39 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 17 Oct 2018, 07:02 PM

Hello All,

Is it possible to validate the text enter as the user types (ie validate on TextChanged) as opposed to validating as focus is changed?

Thanks!!

8 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 18 Oct 2018, 09:54 AM
Hello Scott,

This is not supported by the regex mask. Consider using another mask. What is the format that you want to parse in this case?

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik
Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Scott
Top achievements
Rank 1
answered on 18 Oct 2018, 05:48 PM

Thanks, I'm looking to restrict input to alphanumeric, underscore and dash. I used the Key Press event check instead and it works for me.

One other question,

I'd like to include a prefix in a textbox, maybe the masked edit box, that is based on a selection from a drop down. Ie, the user picks a project from the drop down and I want to include the 4 digit project ID in the textbox as a non changeable prefix. I currently fake it by placing a label in front of the text box. Any ideas for that?

0
Dimitar
Telerik team
answered on 19 Oct 2018, 10:50 AM
Hello Scott,

You can use the approach from this article: Adding Buttons to RadTextBox. Here is an example that demonstrates it:
LightVisualElement label = new LightVisualElement();
 
label.Margin = new Padding(0, 0, -3, 0);
label.Text = "9999";
 
RadTextBoxItem tbItem = this.radMaskedEditBox1.MaskedEditBoxElement.TextBoxItem;
this.radMaskedEditBox1.MaskedEditBoxElement.Children.Remove(tbItem);
DockLayoutPanel dockPanel = new DockLayoutPanel();
dockPanel.Children.Add(label);
dockPanel.Children.Add(tbItem);
DockLayoutPanel.SetDock(tbItem, Telerik.WinControls.Layouts.Dock.Right);
DockLayoutPanel.SetDock(label, Telerik.WinControls.Layouts.Dock.Left);
this.radMaskedEditBox1.MaskedEditBoxElement.Children.Add(dockPanel);

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Scott
Top achievements
Rank 1
answered on 30 Oct 2018, 04:42 PM

Hi, I'm attempting to use this example in a RadTreeViewNode. Is it possible to use the DockLayoutPanel in a tree view node?

If not. Is there a way to get a similar behavior from a StackLayoutElement? Using the StackLayoutElement, the Textbox overlaps the label, the textbox doesn't size to fit the nulltext value, and as you type the textbox moves to the right. See the attached images.

0
Scott
Top achievements
Rank 1
answered on 30 Oct 2018, 04:52 PM

One last behavior with the textbox in my code and the forum sample https://www.telerik.com/forums/custom-nodes-in-tree-view. When the textbox you're typing in loses focus, the text is also removed.

 

0
Dimitar
Telerik team
answered on 31 Oct 2018, 10:32 AM
Hello Scott,

Yes, it is possible to use DockLayoutPanel just like any other elements. An example is available here: DockLayout.

In addition, I cannot suggest a solution before examining your implementation. Would it be possible to share the code of the custom node element?

I am looking forward to your reply.

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Scott
Top achievements
Rank 1
answered on 31 Oct 2018, 11:10 PM

Thanks Ditmar, Focusing on the first questions in this post. I'm creating the DockLayoutPanels dynamically and the sample appears to  assume that I've already declared the DockLayoutPanel at design time.

Is it a simple change to address a dynamic build?

Building on my previous sample. DockLayoutPanel is not declared.

Thank you so much for your help!

Imports Telerik.WinControls.UI
Imports Telerik.WinControls
Public Class RadForm1
    Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim rtvTest As Telerik.WinControls.UI.RadTreeView = tvProjectPath
        tvProjectPath.Nodes.Clear()
        Dim DFSRootNode As New RadTreeNode("Root0")
        Dim ProdDataNode As New RadTreeNode("Child1")
        Dim JobsNode As New RadTreeNode("Child2")
        Dim ProjectRoot As New RadTreeNode("Child3")
        'Dim ProjectFolder As New CustomTreeNodeElement()
        tvProjectPath.Nodes.Add(DFSRootNode)
        DFSRootNode.Nodes.Add(ProdDataNode)
        ProdDataNode.Nodes.Add(JobsNode)
        JobsNode.Nodes.Add(ProjectRoot)
        'ProjectRoot.TreeViewElement =
    End Sub
    Private Sub CustomNodes_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim test As String = ""
 
        Me.tvProjectPath.ExpandAll()
    End Sub
    Private Sub TreeViewElement_CreateNodeElement(sender As Object, e As Telerik.WinControls.UI.CreateTreeNodeElementEventArgs) Handles tvProjectPath.CreateNodeElement
        e.NodeElement = New CustomTreeNodeElement()
    End Sub
End Class
Public Class CustomContentElement
    Inherits TreeNodeContentElement
    Private nodeContentContainer As StackLayoutElement
    Private nodeLabel As RadLabelElement
    Private nodeTextBox As RadTextBoxControlElement
 
    Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
        Get
            Return GetType(TreeNodeElement)
        End Get
    End Property
    Protected Overrides Sub InitializeFields()
        MyBase.InitializeFields()
        Me.StretchHorizontally = True
    End Sub
    Protected Overrides Sub CreateChildElements()
        MyBase.CreateChildElements()
        nodeContentContainer = New StackLayoutElement
        nodeContentContainer.Orientation = Orientation.Horizontal
        nodeContentContainer.StretchHorizontally = True
        nodeContentContainer.StretchVertically = False
        nodeLabel = New RadLabelElement
        Me.Children.Add(nodeLabel)
        nodeTextBox = New RadTextBoxControlElement
        Me.Children.Add(nodeTextBox)
 
    End Sub
 
End Class
Public Class CustomTreeNodeElement
    Inherits TreeNodeElement
    Protected Overrides Function CreateContentElement() As TreeNodeContentElement
        Return New CustomContentElement()
        'Dim node As RadTreeNode = Me.Data
 
    End Function
 
    Protected Overrides ReadOnly Property ThemeEffectiveType() As Type
        Get
            Return GetType(TreeNodeElement)
        End Get
    End Property
 
End Class
 
Public Class MyDockLayoutPanelElement
        Inherits RadElement
        Protected Overrides Sub CreateChildElements()
            Dim button1 As New RadButtonElement("button1")
            DockLayoutPanel.SetDock(button1, Telerik.WinControls.Layouts.Dock.Left)
            Dim button2 As New RadButtonElement("button2")
            DockLayoutPanel.SetDock(button2, Telerik.WinControls.Layouts.Dock.Right)
            Dim button3 As New RadButtonElement("button3")
            DockLayoutPanel.SetDock(button3, Telerik.WinControls.Layouts.Dock.Top)
            Dim button4 As New RadButtonElement("button4")
            DockLayoutPanel.SetDock(button4, Telerik.WinControls.Layouts.Dock.Bottom)
            Dim dockPanel As New DockLayoutPanel()
            dockPanel.Children.Add(button4)
            dockPanel.Children.Add(button3)
            dockPanel.Children.Add(button2)
            dockPanel.Children.Add(button1)
        End Sub
    End Class
Public Class MyDockLayoutPanelControl
    Inherits RadControl
    Protected Overrides Sub CreateChildItems(parent As RadElement)
        MyBase.CreateChildItems(parent)
        parent.Children.Add(New MyDockLayoutPanelElement())
    End Sub
End Class

0
Dimitar
Telerik team
answered on 01 Nov 2018, 08:28 AM
Hi Scott,

This is a static method and you do not need to declare an instance. You need to add the following namespace:
Imports Telerik.WinControls.Layouts

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
MaskedEditBox
Asked by
Scott
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Scott
Top achievements
Rank 1
Share this question
or