Hi,
There is not an event but you can try something like this.
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Dim da As SqlClient.SqlDataAdapter
Dim ds As New DataSet
Dim WithEvents cm As CurrencyManager
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim conn As SqlConnection
Dim strConn As String
strConn = "Server = (local);"
strConn &= "Database = NorthWind; Integrated Security = SSPI;"
conn = New SqlConnection(strConn)
da = New SqlDataAdapter("Select * from products", conn)
da.Fill(ds, "Products")
DataGrid1.DataSource = ds.Tables("Products")
cm = CType(Me.BindingContext(DataGrid1.DataSource), CurrencyManager)
Button1.Enabled = False
End Sub
Private Sub cm_CurrentChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cm.CurrentChanged
Button1.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cmd As New SqlCommandBuilder(da)
da.Update(ds.Tables("Products"))
ds.AcceptChanges()
Button1.Enabled = False
End Sub
Private Sub cm_PositionChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cm.PositionChanged
If cm.Position >= ds.Tables("Products").Rows.Count Then
' new row is added
Button1.Enabled = True
' you can try something like this
DataGrid1.Item(cm.Position, 1) = "Test"
End If
End Sub
End Class
Ken
-------------------
<max> wrote in message news:01********************************@4ax.com...
I can generate this error by NOT assigning a tableName to the view:
at System.Windows.Forms.DataGrid.AddNewRow()
at System.Windows.Forms.DataGridAddNewRow.OnEdit()
Is there any possibility of getting an event from the AddNewRow()? I
would like to make some changes to the row prior to the user typing in
the DataGrid.
Thanks,
--max