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 © 2015. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: DataGridView with ArrayList
- '
- ' Author: Joseph L. Bolen
- ' Date Created: May 2015
- '
- ' Description: Use ArrayList for DataSource for DataGridView.
- '
- ' Documentation is at:
- ' App's Visual Basic .NET code is at http://pastebin.com/aFzzjXLA
- '-------------------------------------------------------------------------------------------
- Public Class MainForm
- Private myArrayList As New ArrayList()
- Private currencyMgmr As CurrencyManager
- Private Sub MainForm_Load(sender As Object, e As EventArgs) _
- Handles MyBase.Load
- With myArrayList
- .Add(New Contributers("USA", "Joe", "Bolen"))
- .Add(New Contributers("India", "Vinod", "Kc"))
- .Add(New Contributers("USA", "Michael", "Corbett"))
- End With
- With DataGridView1
- .DataSource = myArrayList
- .Columns("Country").Visible = False
- .Columns("FirstName").HeaderText = "First Name"
- .Columns("LastName").HeaderText = "Last Name"
- .SelectionMode = DataGridViewSelectionMode.FullRowSelect
- .MultiSelect = False
- End With
- currencyMgmr = CType(DataGridView1.BindingContext(myArrayList), CurrencyManager)
- End Sub
- #Region " Navigation"
- Private Sub FirstButton_Click(sender As Object, e As EventArgs) _
- Handles FirstButton.Click
- currencyMgmr.Position = 0
- End Sub
- Private Sub PreviousButton_Click(sender As Object, e As EventArgs) _
- Handles PreviousButton.Click
- currencyMgmr.Position -= 1
- End Sub
- Private Sub NextButton_Click(sender As Object, e As EventArgs) _
- Handles NextButton.Click
- currencyMgmr.Position += 1
- End Sub
- Private Sub LastButton_Click(sender As Object, e As EventArgs) _
- Handles LastButton.Click
- currencyMgmr.Position = myArrayList.Count - 1
- End Sub
- #End Region
- End Class
- Public Class Contributers
- Public Property Country As String
- Public Property FirstName As String
- Public Property LastName As String
- Sub New(ByVal countryParm As String, ByVal firstNameParm As String, ByVal lastNameParm As String)
- Country = countryParm
- FirstName = firstNameParm
- LastName = lastNameParm
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment