Hi,
I have datatable that I'm updating based on a response from a server. I receive a raw value and update the row, which triggers the rowchanged event. That is fine, the problem is then I update the row with the calibrated value and the same event is triggered. Is there a way to turn the event off under certain conditions?
Here is the code I update the table with
Here is the event handler
To clear any confusion with the e.row.calibratedvalue, these were created using the data source wizard - hence are in the drop down list. I have used DataTable and DataRow above in place of the names of the classes of my wizard created tables etc..
So where I have highlighted "THIS IS THE PROBLEM" is where the same event handler seems to be called again, which of course I don't want. I only want the event to trigger when the raw value column is updated. Is there a simple way to do this?
Thanks,
N
I have datatable that I'm updating based on a response from a server. I receive a raw value and update the row, which triggers the rowchanged event. That is fine, the problem is then I update the row with the calibrated value and the same event is triggered. Is there a way to turn the event off under certain conditions?
Here is the code I update the table with
Code:
Private Sub ReceiveMessage(Message as MyMessage)
Dim RowsAffected As DataRow()
RowsAffected = me.Store.Select("Address=" & Message.Address) ' Store is the datatable of all rows, here I'm filtered on those with the same address field
NoRows = RowsAffected.GetUpperBound(0)
Me.Store.BeingLoadData()
For I = 0 To NoRows
RawValue = Message.Data
If RowsAffected(I).IsRawValueNull Then
' Just set the data
RowsAffected(I).RawVal = RawValue ' RowChanged Event Triggered hereElseIf Not RawValue = RowsAffected(I).RawVal Then
RowsAffected(I).RawVal = RawValue ' RowChanged Event Triggered hereEnd IfEnd IfNext IMe.Store.EndLoadData()
End Sub
Code:
' I add the handler for this during initialisation using addhandler MyTable_RowChanged, AddressOf DataValues_Changed
Private Sub DataValues_Changed(ByVal Sender as Object, ByVal e As DataRowChangeEvent)
Select Case e.Action
Case System.Data.DataRowAction.Change
e.row.beingedit()
Dim CalValue = e.row.RawVal * CalNumber ' This cal number doesn't matter for the sake of this thread!
e.row.CalibratedValue = CalValue
e.row.endedit() ***** THIS IS THE PROBLEM ***End SelectEnd Sub
So where I have highlighted "THIS IS THE PROBLEM" is where the same event handler seems to be called again, which of course I don't want. I only want the event to trigger when the raw value column is updated. Is there a simple way to do this?
Thanks,
N