Click here to Skip to main content
15,886,258 members
Articles / Programming Languages / Visual Basic 10

Having fun with custom collections!

Rate me:
Please Sign up or sign in to vote.
4.91/5 (71 votes)
14 Oct 2011CPOL44 min read 186.1K   2.9K   121  
Creating custom collections from IEnumerable(T) to IDictionary(T) and everything in between!
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmCult
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
		Me.components = New System.ComponentModel.Container()
		Me.dgvCult = New System.Windows.Forms.DataGridView()
		Me.colMark = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.colRank = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.colFirstName = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.colLastName = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.colAge = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.colFullName = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.btnAdd = New System.Windows.Forms.Button()
		Me.txtFirstName = New System.Windows.Forms.TextBox()
		Me.lblFirstName = New System.Windows.Forms.Label()
		Me.lblLastName = New System.Windows.Forms.Label()
		Me.txtLastName = New System.Windows.Forms.TextBox()
		Me.txtAge = New System.Windows.Forms.TextBox()
		Me.lblAge = New System.Windows.Forms.Label()
		Me.btnRemove = New System.Windows.Forms.Button()
		Me.errorProvider = New System.Windows.Forms.ErrorProvider(Me.components)
		Me.lblCount = New System.Windows.Forms.Label()
		Me.bndCult = New System.Windows.Forms.BindingSource(Me.components)
		Me.MarkDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.RankDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.FirstNameDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.LastNameDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.AgeDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn()
		Me.FullNameDataGridViewTextBoxColumn = New System.Windows.Forms.DataGridViewTextBoxColumn()
		CType(Me.dgvCult, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.errorProvider, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.bndCult, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.SuspendLayout()
		'
		'dgvCult
		'
		Me.dgvCult.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
					Or System.Windows.Forms.AnchorStyles.Left) _
					Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
		Me.dgvCult.AutoGenerateColumns = False
		Me.dgvCult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
		Me.dgvCult.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.colMark, Me.colRank, Me.colFirstName, Me.colLastName, Me.colAge, Me.colFullName, Me.MarkDataGridViewTextBoxColumn, Me.RankDataGridViewTextBoxColumn, Me.FirstNameDataGridViewTextBoxColumn, Me.LastNameDataGridViewTextBoxColumn, Me.AgeDataGridViewTextBoxColumn, Me.FullNameDataGridViewTextBoxColumn})
		Me.dgvCult.DataSource = Me.bndCult
		Me.dgvCult.Location = New System.Drawing.Point(15, 134)
		Me.dgvCult.Name = "dgvCult"
		Me.dgvCult.Size = New System.Drawing.Size(795, 459)
		Me.dgvCult.TabIndex = 8
		'
		'colMark
		'
		Me.colMark.DataPropertyName = "Mark"
		Me.colMark.HeaderText = "Mark"
		Me.colMark.Name = "colMark"
		Me.colMark.ReadOnly = True
		Me.colMark.Width = 75
		'
		'colRank
		'
		Me.colRank.DataPropertyName = "Rank"
		Me.colRank.HeaderText = "Rank"
		Me.colRank.Name = "colRank"
		Me.colRank.ReadOnly = True
		'
		'colFirstName
		'
		Me.colFirstName.DataPropertyName = "FirstName"
		Me.colFirstName.HeaderText = "First name"
		Me.colFirstName.Name = "colFirstName"
		Me.colFirstName.ReadOnly = True
		Me.colFirstName.Width = 125
		'
		'colLastName
		'
		Me.colLastName.DataPropertyName = "LastName"
		Me.colLastName.HeaderText = "Last name"
		Me.colLastName.Name = "colLastName"
		Me.colLastName.ReadOnly = True
		Me.colLastName.Width = 125
		'
		'colAge
		'
		Me.colAge.DataPropertyName = "Age"
		Me.colAge.HeaderText = "Age"
		Me.colAge.Name = "colAge"
		Me.colAge.ReadOnly = True
		Me.colAge.Width = 75
		'
		'colFullName
		'
		Me.colFullName.DataPropertyName = "FullName"
		Me.colFullName.HeaderText = "Full name"
		Me.colFullName.Name = "colFullName"
		Me.colFullName.ReadOnly = True
		Me.colFullName.Width = 250
		'
		'btnAdd
		'
		Me.btnAdd.Location = New System.Drawing.Point(15, 105)
		Me.btnAdd.Name = "btnAdd"
		Me.btnAdd.Size = New System.Drawing.Size(75, 23)
		Me.btnAdd.TabIndex = 6
		Me.btnAdd.Text = "Add"
		Me.btnAdd.UseVisualStyleBackColor = True
		'
		'txtFirstName
		'
		Me.txtFirstName.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
					Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
		Me.txtFirstName.Location = New System.Drawing.Point(111, 6)
		Me.txtFirstName.Name = "txtFirstName"
		Me.txtFirstName.Size = New System.Drawing.Size(356, 20)
		Me.txtFirstName.TabIndex = 1
		'
		'lblFirstName
		'
		Me.lblFirstName.AutoSize = True
		Me.lblFirstName.Location = New System.Drawing.Point(12, 9)
		Me.lblFirstName.Name = "lblFirstName"
		Me.lblFirstName.Size = New System.Drawing.Size(58, 13)
		Me.lblFirstName.TabIndex = 0
		Me.lblFirstName.Text = "&First name:"
		'
		'lblLastName
		'
		Me.lblLastName.AutoSize = True
		Me.lblLastName.Location = New System.Drawing.Point(12, 35)
		Me.lblLastName.Name = "lblLastName"
		Me.lblLastName.Size = New System.Drawing.Size(59, 13)
		Me.lblLastName.TabIndex = 2
		Me.lblLastName.Text = "&Last name:"
		'
		'txtLastName
		'
		Me.txtLastName.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
					Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
		Me.txtLastName.Location = New System.Drawing.Point(111, 32)
		Me.txtLastName.Name = "txtLastName"
		Me.txtLastName.Size = New System.Drawing.Size(356, 20)
		Me.txtLastName.TabIndex = 3
		'
		'txtAge
		'
		Me.txtAge.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
					Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
		Me.txtAge.Location = New System.Drawing.Point(111, 58)
		Me.txtAge.Name = "txtAge"
		Me.txtAge.Size = New System.Drawing.Size(356, 20)
		Me.txtAge.TabIndex = 5
		'
		'lblAge
		'
		Me.lblAge.AutoSize = True
		Me.lblAge.Location = New System.Drawing.Point(12, 61)
		Me.lblAge.Name = "lblAge"
		Me.lblAge.Size = New System.Drawing.Size(29, 13)
		Me.lblAge.TabIndex = 4
		Me.lblAge.Text = "&Age:"
		'
		'btnRemove
		'
		Me.btnRemove.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
		Me.btnRemove.Location = New System.Drawing.Point(735, 105)
		Me.btnRemove.Name = "btnRemove"
		Me.btnRemove.Size = New System.Drawing.Size(75, 23)
		Me.btnRemove.TabIndex = 7
		Me.btnRemove.Text = "Remove"
		Me.btnRemove.UseVisualStyleBackColor = True
		'
		'errorProvider
		'
		Me.errorProvider.ContainerControl = Me
		'
		'lblCount
		'
		Me.lblCount.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
		Me.lblCount.AutoSize = True
		Me.lblCount.Location = New System.Drawing.Point(15, 596)
		Me.lblCount.Name = "lblCount"
		Me.lblCount.Size = New System.Drawing.Size(124, 13)
		Me.lblCount.TabIndex = 9
		Me.lblCount.Text = "Number of cult members:"
		'
		'bndCult
		'
		Me.bndCult.DataSource = GetType(TheCult.Cult)
		'
		'MarkDataGridViewTextBoxColumn
		'
		Me.MarkDataGridViewTextBoxColumn.DataPropertyName = "Mark"
		Me.MarkDataGridViewTextBoxColumn.HeaderText = "Mark"
		Me.MarkDataGridViewTextBoxColumn.Name = "MarkDataGridViewTextBoxColumn"
		Me.MarkDataGridViewTextBoxColumn.ReadOnly = True
		'
		'RankDataGridViewTextBoxColumn
		'
		Me.RankDataGridViewTextBoxColumn.DataPropertyName = "Rank"
		Me.RankDataGridViewTextBoxColumn.HeaderText = "Rank"
		Me.RankDataGridViewTextBoxColumn.Name = "RankDataGridViewTextBoxColumn"
		Me.RankDataGridViewTextBoxColumn.ReadOnly = True
		'
		'FirstNameDataGridViewTextBoxColumn
		'
		Me.FirstNameDataGridViewTextBoxColumn.DataPropertyName = "FirstName"
		Me.FirstNameDataGridViewTextBoxColumn.HeaderText = "FirstName"
		Me.FirstNameDataGridViewTextBoxColumn.Name = "FirstNameDataGridViewTextBoxColumn"
		'
		'LastNameDataGridViewTextBoxColumn
		'
		Me.LastNameDataGridViewTextBoxColumn.DataPropertyName = "LastName"
		Me.LastNameDataGridViewTextBoxColumn.HeaderText = "LastName"
		Me.LastNameDataGridViewTextBoxColumn.Name = "LastNameDataGridViewTextBoxColumn"
		'
		'AgeDataGridViewTextBoxColumn
		'
		Me.AgeDataGridViewTextBoxColumn.DataPropertyName = "Age"
		Me.AgeDataGridViewTextBoxColumn.HeaderText = "Age"
		Me.AgeDataGridViewTextBoxColumn.Name = "AgeDataGridViewTextBoxColumn"
		'
		'FullNameDataGridViewTextBoxColumn
		'
		Me.FullNameDataGridViewTextBoxColumn.DataPropertyName = "FullName"
		Me.FullNameDataGridViewTextBoxColumn.HeaderText = "FullName"
		Me.FullNameDataGridViewTextBoxColumn.Name = "FullNameDataGridViewTextBoxColumn"
		Me.FullNameDataGridViewTextBoxColumn.ReadOnly = True
		'
		'frmCult
		'
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.ClientSize = New System.Drawing.Size(822, 624)
		Me.Controls.Add(Me.lblCount)
		Me.Controls.Add(Me.btnRemove)
		Me.Controls.Add(Me.lblAge)
		Me.Controls.Add(Me.txtAge)
		Me.Controls.Add(Me.txtLastName)
		Me.Controls.Add(Me.lblLastName)
		Me.Controls.Add(Me.lblFirstName)
		Me.Controls.Add(Me.txtFirstName)
		Me.Controls.Add(Me.btnAdd)
		Me.Controls.Add(Me.dgvCult)
		Me.MinimumSize = New System.Drawing.Size(583, 498)
		Me.Name = "frmCult"
		Me.Text = "Cult"
		CType(Me.dgvCult, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.errorProvider, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.bndCult, System.ComponentModel.ISupportInitialize).EndInit()
		Me.ResumeLayout(False)
		Me.PerformLayout()

	End Sub
	Friend WithEvents dgvCult As System.Windows.Forms.DataGridView
	Friend WithEvents btnAdd As System.Windows.Forms.Button
	Friend WithEvents txtFirstName As System.Windows.Forms.TextBox
	Friend WithEvents lblFirstName As System.Windows.Forms.Label
	Friend WithEvents lblLastName As System.Windows.Forms.Label
	Friend WithEvents txtLastName As System.Windows.Forms.TextBox
	Friend WithEvents txtAge As System.Windows.Forms.TextBox
	Friend WithEvents lblAge As System.Windows.Forms.Label
	Friend WithEvents btnRemove As System.Windows.Forms.Button
	Friend WithEvents errorProvider As System.Windows.Forms.ErrorProvider
	Friend WithEvents colMark As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents colRank As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents colFirstName As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents colLastName As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents colAge As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents colFullName As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents lblCount As System.Windows.Forms.Label
	Friend WithEvents MarkDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents RankDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents FirstNameDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents LastNameDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents AgeDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents FullNameDataGridViewTextBoxColumn As System.Windows.Forms.DataGridViewTextBoxColumn
	Friend WithEvents bndCult As System.Windows.Forms.BindingSource
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
CEO JUUN Software
Netherlands Netherlands
Sander Rossel is a Microsoft certified professional developer with experience and expertise in .NET and .NET Core (C#, ASP.NET, and Entity Framework), SQL Server, Azure, Azure DevOps, JavaScript, MongoDB, and other technologies.

He is the owner of JUUN Software, a company specializing in custom software. JUUN Software uses modern, but proven technologies, such as .NET Core, Azure and Azure DevOps.

You can't miss his books on Amazon and his free e-books on Syncfusion!

He wrote a JavaScript LINQ library, arrgh.js (works in IE8+, Edge, Firefox, Chrome, and probably everything else).

Check out his prize-winning articles on CodeProject as well!

Comments and Discussions