hi all,
on the custom inherited control i created, i noticed that when i bind my custom property to a data column, if that data column returns a value other than Null it always return a datarowstate of modified even if there were no changes.
to produce this issue, i have below a sample code for a test inherited control
create a form, add the usual objects necessary for data bindings, (datasource, datatable). make sure the data column bound to this TestControl will return non null values.
also create a procedure for position changed to catch the datarowstate like below...
Note that i used Position - 1 so that when you go to the next record, it will show you the rowstate of the previous record.
on your Form_Load add the ff:
don't make any changes to the current record before you go to the next record. you will see that the rowstate will still return Modified.
can anyone share their thoughts on this?
thanks
on the custom inherited control i created, i noticed that when i bind my custom property to a data column, if that data column returns a value other than Null it always return a datarowstate of modified even if there were no changes.
to produce this issue, i have below a sample code for a test inherited control
VB.NET:
Imports System.Windows.Forms
Imports System.ComponentModel
Public Class TestControl
Inherits TextBox
<Bindable(True)> _
Public Property Value() As String
Get
Return MyBase.Text
End Get
Set(ByVal value As String)
MyBase.Text = value
End Set
End Property
End Class
create a form, add the usual objects necessary for data bindings, (datasource, datatable). make sure the data column bound to this TestControl will return non null values.
also create a procedure for position changed to catch the datarowstate like below...
VB.NET:
Private Sub PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim rowstate As DataRowState = DataRowState.Unchanged
rowstate = Me.YourDataSet.YourDataTable.Rows(Me.YourBindingSource.Position - 1).RowState
MsgBox(rowstate.ToString)
End Sub
Note that i used Position - 1 so that when you go to the next record, it will show you the rowstate of the previous record.
on your Form_Load add the ff:
VB.NET:
AddHandler YourBindingSource.PositionChanged, AddressOf PositionChanged
don't make any changes to the current record before you go to the next record. you will see that the rowstate will still return Modified.
can anyone share their thoughts on this?
thanks