DataTable Events?

  • Thread starter Thread starter Dave Veeneman
  • Start date Start date
D

Dave Veeneman

I am getting started with DataTables and the DataGrid control. I want to
find out when the user adds a row to a DataGrid, but I can't find a 'new
row' or 'row added' method in either the DataGrid control or the DataTable
class.

I have bound a DataGrid to a stand-alone, in-memory DataTable. The user can
edit the DataGrid cells and add new rows. When the user adds a new row, the
calls all show "(null)", since they don't yet have values. I'd like to know
when the user adds a new row, so I can plug in some default values, or do
something to supress the "(null)" display in the cells. Is there an easy way
to do that? Is an event fired when a user adds a new row? Thanks.
 
Hi
You can add Event Handler for RowChanged Event or rowChanging Event
Code may look some thing like this

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.SqlDataAdapter1.Fill(Me.DataSet1)
AddHandler Me.DataSet1.Tables("Customers").RowChanged, AddressOf
Me.RowChanged
Me.DataGrid1.DataSource = Me.DataSet1
Me.DataGrid1.DataMember = "Customers"
End Sub

Private Sub RowChanged(ByVal sender As Object, ByVal e As
System.Data.DataRowChangeEventArgs)

' Process your Logic Here
End Sub

--------------------
 
Back
Top