Click here to Skip to main content
15,893,814 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.8K   5.5K   44  
Dynamic data forms.
Imports System.Collections.ObjectModel
Imports Curion.WPF.Controls
Public Class ListDynamicObject
	Private obj As Object
	Sub New()
		Using New ContextDefaults
			Defaults("Form.MakeHeaders") = Function() New MakeSimpleHeader With {.Background = New SolidColorBrush(Color.FromArgb(80, 220, 220, 220))}

			InitializeComponent()

			Dim list As New ObservableCollection(Of DynObj)
			list.Add(NewDynObj("Larry", "555-1212", 31, True, #5/15/2013#))
			list.Add(NewDynObj("Mark", "555-1213", 32, False, #5/16/2013#))
			list.Add(NewDynObj("Bob", "555-1214", 33, True, #5/17/2013#))
			list.Add(NewDynObj("Greg", "555-1215", 34, False, #5/18/2013#))
			list.Add(NewDynObj("Eric", "555-1216", 35, True, #5/19/2013#))
			obj = list
			ctlForm.Title = StringTitle("ObservableCollection of DynamicObject", Windows.HorizontalAlignment.Left)
			Dim clr As Color = TryFindResource("AccentColor")
			clr.A = 20
			ctlForm.Background = New LinearGradientBrush(Color.FromArgb(20, 220, 220, 220), clr, 45)
			ctlForm.ItemsSource = obj
			ctlForm.Column("Phone").SuppressHeading = True
			ctlForm.MakeForm() ' Regenerate form without heading
		End Using
	End Sub
	Function NewDynObj(Name As String, Phone As String, Age As Integer, IsActive As Boolean, Hired As Date) As DynObj
		Dim obj As Object = New DynObj
		obj.Name = Name
		obj.Phone = Phone
		obj.Age = Age
		obj.IsActive = IsActive
		obj.Hired = Hired
		Return obj
	End Function
	Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
		Dim view = ctlForm.View
		Dim cur = view.CurrentItem
		Call ShowResults(cur)
	End Sub
	Private Sub btnPrior_Click(sender As Object, e As RoutedEventArgs) Handles btnPrior.Click
		Dim view = ctlForm.View
		view.MoveCurrentToPrevious()
		If view.CurrentItem Is Nothing Then
			view.MoveCurrentToFirst()
		End If
	End Sub
	Private Sub btnNext_Click(sender As Object, e As RoutedEventArgs) Handles btnNext.Click
		Dim view = ctlForm.View
		view.MoveCurrentToNext()
		If view.CurrentItem Is Nothing Then
			view.MoveCurrentToLast()
		End If
	End Sub
	Private Sub btnNext_PreviewMouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs) Handles btnNext.PreviewMouseLeftButtonUp, btnPrior.PreviewMouseLeftButtonUp
		Dispatcher.BeginInvoke(Sub() ctlForm.FocusFirst())
	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