Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Windows Form datagridview Edit and Insert row

Posted on 2014-04-30
2
Medium Priority
?
1,163 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 2000 total points
ID: 40037473
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

972 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