Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DataGridView

Posted on 2013-05-25
3
Medium Priority
?
416 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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