Solved

Windows Form datagridview Edit and Insert row

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Word Template Mail merge with vb.net 4 56
Limiting string to two deciamls 18 49
help with issues with ReportViewer in VS2015 5 37
LINQ - C# to VB convertion 12 45
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

930 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

10 Experts available now in Live!

Get 1:1 Help Now