Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '------------------------------------------------------------------------------------------
- ' Notice of My Copyright and Intellectual Property Rights
- '
- ' Any intellectual property contained within the program by Joseph L. Bolen remains the
- ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
- ' publish or provide such intellectual property to any other person or entity for any
- ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
- '
- ' Copyright © 2017. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: Fun With Classes
- '
- ' Author: Joseph L. Bolen
- ' Date Created: 25 APR 2017
- '
- ' Description: Simple demo to show a simple class using auto-implemented
- ' properties; the use of a List(Of T) collection that is
- ' loaded with an initialization list; the use of LINQ to
- ' sort the collection; and, assigning the sorted collection
- ' to a DataGridView for display.
- '
- ' Documentation is at:
- ' App's Visual Basic .NET code is at https://pastebin.com/yNkKhxe0
- ' Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
- '-------------------------------------------------------------------------------------------
- Public Class MainForm
- Private Sub MainForm_Load(sender As Object, e As EventArgs) _
- Handles MyBase.Load
- ' Using a List(Of T) and an initialization list.
- Dim people As New List(Of Person) From
- {New Person With {.FirstName = "Joe", .LastName = "Bolen", .Gender = "M"},
- New Person With {.FirstName = "Tim", .LastName = "Hamilton", .Gender = "M"},
- New Person With {.FirstName = "Cathy", .LastName = "Cunningham", .Gender = "F"},
- New Person With {.FirstName = "Sally", .LastName = "Peterson", .Gender = "F"},
- New Person With {.FirstName = "Patrica", .LastName = "Adele", .Gender = "F"}}
- ' LINQ method to order by LastName, then FirstName.
- Dim query = people.OrderBy(Function(p) p.LastName).ThenBy(Function(p) p.FirstName)
- ' Assign the query to the DataGridView's datasource
- MyDGV.DataSource = query.ToList
- End Sub
- End Class
- ' Simple Auto-implemented properties of the Person class
- Public Class Person
- Public Property FirstName As String
- Public Property LastName As String
- Public Property Gender As String
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement