Solved

Windows Form datagridview Edit and Insert row

Posted on 2014-04-30
2
1,118 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
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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 WebRequest Code from JSON curl 7 84
vb.net class 3 28
MailAddress in vb 4 35
Code enhancement 4 32
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

679 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