Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:10:29+00:00 2026-05-30T17:10:29+00:00

Dim datatable_default_view As DataTable = _datatable.DefaultView.ToTable Dim servicenumber As String = datatable_default_view.Rows.Item(e.RowIndex)(Service Number).ToString ‘gets

  • 0
        Dim datatable_default_view As DataTable = _datatable.DefaultView.ToTable
        Dim servicenumber As String = datatable_default_view.Rows.Item(e.RowIndex)("Service Number").ToString
'gets the service number of the selected row

        If _datatable.PrimaryKey.Length = 0 Then
            Dim keys(0) As DataColumn
            keys(0) = _datatable.Columns("Service Number")
            _datatable.PrimaryKey = keys
        End If

        Dim datarow_edited As DataRow = _datatable.Rows.Find(servicenumber)

        Try
            MsgBox("Record" + datarow_edited("service number") + " was edited")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error")
        End Try

I’ve put this code under the DatagridView_CellEndEdit event

The Problem:
The ‘data_row edited’ variable doesn’t get initialized when exiting the cell in edit mode using the keyboard (ie: pressing the down/up arrow).
If I use the mouse it works as expected. Why is this ? Is it a known bug I’m using VB.net 2008. Please Help

I’ve uploaded a sample project, with sample data here. Check it out if possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:10:31+00:00Added an answer on May 30, 2026 at 5:10 pm

    Just tried you example solution with VS 2010 and it’s working as intended. DataRow gets initialized correctly, also when switching rows with arrow keys.

    Edit:

    Got you now, sorry.

    Looks like some async issue behind the scenes.

    Maybe handling RowChanged event of the datatable itself could be a workaround for you

    Imports System.Data.OleDb
    Public Class Form1
        Private _datatable As DataTable
        Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Members Database.mdb;Persist Security Info=False"
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim connection As New OleDbConnection(conn)
            Dim adapter As OleDbDataAdapter
    
    
            Dim _branchname As String = "A BAUR"
            Dim cmd As String = "Select [Service Number] ,[Name], [Gender], [Subscription]  from " + _branchname.Insert(0, "[") + "]"
            adapter = New OleDbDataAdapter(cmd, conn)
            _datatable = New DataTable
            adapter.Fill(_datatable)
    
    
            If _datatable.PrimaryKey.Length = 0 Then
    
                Dim keys(0) As DataColumn
                keys(0) = _datatable.Columns("Service Number")
                _datatable.PrimaryKey = keys
            End If
    
    
            AddHandler _datatable.RowChanged, AddressOf _datatable_RowChanged
    
            DataGridView1.DataSource = _datatable
    
        End Sub
    
    
        Private Sub _datatable_RowChanged(sender As Object, e As System.Data.DataRowChangeEventArgs)
    
            Dim servicenumber = e.Row("Service Number")
    
            Dim datarow_edited As DataRow = _datatable.Rows.Find(servicenumber)
    
            Try 
                MsgBox("Record" + datarow_edited("service number") + " was edited")
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error")
            End Try
        End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the following DataTable: Dim d As New DataTable() d.Columns.Add(Product, GetType(System.String)) d.Columns.Add(Value, GetType(System.Double)) d.Rows.Add(New
Code. Public Function comb1(ByVal SName As String) As DataTable Dim dt As New DataTable
dim dataType as String toolTip=Marks And Number[String] I want to get the [String] alone.
if i define a table like this: Dim datatable As PdfPTable = New PdfPTable(4)
Consider: Dim line As String Using readFile As New StreamReader(SalesUpdateFile) While (line = readFile.ReadLine)
Dim dt As New DataTable Dim da As New SqlDataAdapter(s, c) c.Open() If Not
I have a datatable with verified 10 rows named dtable. I attempt to bind
I populate a DataTable, then sort the DefaultView of that DataTable. When I set
I've embeded the following server side code within <script> tag. <% Dim dataTable As
I'm rewriting/converting some VB-Code: Dim dt As New System.Data.DataTable() Dim dr As System.Data.DataRow =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.