Solved

Windows Form datagridview Edit and Insert row

Posted on 2014-04-30
2
1,101 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
Comment Utility
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
Comment Utility
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

744 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

14 Experts available now in Live!

Get 1:1 Help Now