Solved

DataGridView

Posted on 2013-05-25
3
365 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
  • 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
 

Author Comment

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

Author Closing Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now