Solved

Windows Form datagridview Edit and Insert row

Posted on 2014-04-30
2
1,121 Views
Last Modified: 2014-05-05
Hi,
I have a datagridview in my windows form that is bound to my binding source.  I have the Enable Adding and Enable Editing boxes checked.  I wrote the following in my useraddedrow event to insert new rows into my table and it works but I'm not sure this is the correct place to put it or is there a better event to put my code?  Also, where do I put code if I want to edit an existing row?  

I'm not familiar with windows forms so this is all new to me.

 Private Sub Requests_ProgessDataGridView_UserAddedRow(sender As System.Object, e As System.Windows.Forms.DataGridViewRowEventArgs) Handles Requests_ProgessDataGridView.UserAddedRow
        Try
            Me.Validate()
            Me.Requests_ProgessBindingSource.EndEdit()

            Me.Requests_ProgessTableAdapter.Update(Me.TREQSDataSet.Requests_Progess)
            MessageBox.Show("Update successful")
        Catch ex As System.Exception
            MessageBox.Show("Update failed")
        End Try
    End Sub

Open in new window

0
Comment
Question by:imstac73
[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 Comments
 

Author Comment

by:imstac73
ID: 40032862
I moved it to cellendedit event and now it's working for both edit and insert.  Is this the right place for the code or is it better to put it in a different event.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 40037473
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net creating Contact in Outlook 1 99
VB.Net Data Class 1 49
Best book for Internet security 4 55
VB.NET : Selection Out of Range Parameter Name : Value 22 37
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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