Solved

DataGridView

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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