Solved

DataGridView

Posted on 2013-05-25
3
399 Views
Last Modified: 2013-05-29
I am missing something in my sample code that allows me to save changes in the datagrid back to the structure.  Could I get a good pointer as to what that might be?

Public Class Form1
    Private Tests As New Generic.List(Of testdata)
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Tests.Add(New testdata("John", "Smith", 48))
        Tests.Add(New testdata("Jane", "Smith", 45))
        Tests.Add(New testdata("Andy", "Smith", 19))
        Tests.Add(New testdata("Sally", "Smith", 23))
        With Me.DataGridView1
            Dim binder As New BindingSource
            binder.DataSource = Tests
            .DataSource = binder
            .ReadOnly = False
            .EditMode = DataGridViewEditMode.EditOnKeystroke
            .Columns("Forename").HeaderText = "First Name"
            .Columns("Forename").ReadOnly = True
            .Columns("Surname").HeaderText = "Family Name"
            .Columns("Surname").ReadOnly = True


        End With


    End Sub

    Private Sub DataGridView1_CellEndEdit(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit

    End Sub

    Private Sub DataGridView1_CellLeave(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave

    End Sub
End Class

Public Structure testdata
    Public Sub New(FName As String, SName As String, Years As Integer)
        Forename = FName
        Surname = SName
        Age = Years
    End Sub

    Private _Forename As String
    Public Property Forename As String
        Get
            Return _Forename
        End Get
        Set(value As String)
            _Forename = value
        End Set
    End Property

    Private _Surname As String
    Public Property Surname As String
        Get
            Return _Surname
        End Get
        Set(value As String)
            _Surname = value
        End Set
    End Property

    Private _Age As Integer
    Public Property Age As Integer
        Get
            Return _Age
        End Get
        Set(value As Integer)
            _Age = value
        End Set
    End Property

    Public Property RecordColour As Color

End Structure
0
Comment
Question by:Alyanto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 500 total points
ID: 39197855
Structure is a value type and I think that is the issue. Please try changing it the structure to class.

Thanks
0
 
LVL 1

Author Comment

by:Alyanto
ID: 39200853
Yep that seems to be the issue.  Thanks again :)
0
 
LVL 1

Author Closing Comment

by:Alyanto
ID: 39203746
A1+ result again, thanks :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question