Click here to Skip to main content
15,880,392 members
Articles / Desktop Programming / WPF

CurionLib Dynamic Data Entry Forms

Rate me:
Please Sign up or sign in to vote.
5.00/5 (20 votes)
11 Aug 2013CPOL16 min read 54.6K   5.5K   44  
Dynamic data forms.
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data

Namespace Controls.Form
	Public Class LongColumn
		Inherits BaseColumn
		Public Property MaxLength As Integer
		Public Property TextAlignment As TextAlignment
		Public Property Format As String
		Public Property MinValue As Long
		Public Property MaxValue As Long
		Sub New()
			StyleName = Defaults("Form.Column.Long.StyleName")
			Height = Defaults("Form.Column.Long.Height")
			Width = Defaults("Form.Column.Long.Width")
			SuppressHeading = Defaults("Form.Column.Long.SuppressHeading")
			Stretch = Defaults("Form.Column.Long.Stretch")
			IsRequired = Defaults("Form.Column.Long.IsRequired")
			IsReadonly = Defaults("Form.Column.Long.IsReadonly")
			MaxLength = Defaults("Form.Column.Long.MaxLength")
			TextAlignment = Defaults("Form.Column.Long.TextAlignment")
			Format = Defaults("Form.Column.Long.Format")
			MinValue = Defaults("Form.Column.Long.MinValue")
			MaxValue = Defaults("Form.Column.Long.MaxValue")
		End Sub
		Public Overrides Function CreateControl(form As DataForm) As FrameworkElement
			Dim ctl As TextBox = Nothing
			Dim bind As Binding = Nothing
			Call TextBoxColumn.CreateTextBox(ctl, bind, Me)

			ctl.TextAlignment = Me.TextAlignment
			If Format <> String.Empty Then bind.StringFormat = Format
			If MinValue > Long.MinValue Then bind.ValidationRules.Add(New LongGreaterThan(Path, MinValue))
			If MaxValue < Long.MaxValue Then bind.ValidationRules.Add(New LongLessThan(Path, MaxValue))
			If IsRequired Then bind.ValidationRules.Add(New LongRequired(Path))
			ctl.SetBinding(TextBox.TextProperty, bind)
			If MaxLength > 0 Then
				ctl.MaxLength = MaxLength
			End If
			Return ctl
		End Function
	End Class
End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
I enjoy my wife, living in the woods, my 7 dogs, and learning new things. I like to play with UI stuff and model based coding.

Comments and Discussions