Click here to Skip to main content
15,883,531 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 Curion.WPF.Data

Public Class MakeClass
	Public Function MakeItem(def As String) As List.Row
		Dim cls = MakeClass(def)
		cls.Rows.NewRow()
		Return cls.Rows(0)
	End Function
	Public Function MakeItems(def As String) As List.DataList
		Dim cls = MakeClass(def)
		For i = 1 To 10
			cls.Rows.NewRow()
		Next
		Return cls
	End Function
	Private Function MakeClass(def As String) As List.DataList
		Dim lines() = Split(def, vbCrLf)
		Dim cls As New List.DataList
		For Each item In lines
			If item = String.Empty Then Continue For
			Dim parts() = Split(item, ",")
			Dim name As String = parts(0)
			Dim type As String = "String"
			If parts.Length > 1 Then type = parts(1)
			Select Case LCase(type)
				Case "string" : type = "System.String"
				Case "integer" : type = "System.Int32"
				Case "boolean" : type = "System.Boolean"
				Case "date" : type = "System.DateTime"
				Case "long" : type = "System.Int64"
				Case "decimal" : type = "System.Decimal"
			End Select
			Dim workType = System.Type.GetType(type)
			cls.Columns.Add(name, , workType)
		Next
		Return cls
	End Function
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