Click here to Skip to main content
15,896,550 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.9K   5.5K   44  
Dynamic data forms.
Imports Curion.WPF.Controls
Imports System.Text

Class MainWindow
	Private builder As New FormBuilder
	'Private cmd As New MyCommands With {.builder = builder, .win = Me}
	Private cmd As New MyCommands
	Public classMaker As New MakeClass
	Sub New()
		Using New ContextDefaults
			Defaults("Form.Column.SimpleHeader.Width") = 150.0#
			Defaults("Form.LineSpacing") = 0.0#
			Defaults("Form.Column.Memo.TextWrapping") = TextWrapping.NoWrap
			InitializeComponent()
			With DirectCast(ctlForm.ColumnMaker, Form.MakeSimpleColumns)
				.ColumnMapperExceptions.Add("Layout", CType(Function(obj, header, path) New Form.MemoColumnFactory With {.Header = CamelToName(header), .Path = GetPath(obj, path), .Height = 230, .AcceptsReturn = True}, Form.CreateControl))
				.ColumnMapperExceptions.Add("ClassDef", CType(Function(obj, header, path) New Form.MemoColumnFactory With {.Header = CamelToName(header), .Path = GetPath(obj, path), .Height = 230, .AcceptsReturn = True}, Form.CreateControl))
			End With
			builder.Layout = My.Resources.initialLayout
			builder.ClassDef = My.Resources.initialClassDef
			builder.CsvColumns = My.Resources.intialColumns
			builder.TitleContent = StringTitle("Customer", Windows.TextAlignment.Center)
			ctlForm.CommandSource = cmd
			ctlForm.DataContext = builder
			'cmd.container = ctlContainer
			'cmd.Update()
		End Using
		Call btnUpdate_Click(Me, Nothing)
	End Sub

	Private Sub btnUpdate_Click(sender As Object, e As RoutedEventArgs) Handles btnUpdate.Click
		ctlContainer.Children.Clear()
		Dim form = builder.MakeForm
		ctlContainer.Children.Add(form)
		If builder.HasItems Then
			DirectCast(form, Form.ItemsForm).ItemsSource = Me.classMaker.MakeItems(builder.ClassDef)
		Else
			form.DataContext = Me.classMaker.MakeItem(builder.ClassDef)
		End If
	End Sub
End Class

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