UserControl DataBinding

  • Thread starter Thread starter Nathan Carroll
  • Start date Start date
N

Nathan Carroll

I have a user control that functions like a combo box. The problem I have
with it is when I go to getChanges from the datatable it always reports rows
as being changed. I bind to this SelectedValue by
me.DataBindings.Add(New Binding("SelectedValue", dataset,
"tablename.fieldname")) . What is causing the datarow to have changes? I
know that the proximately it comes from the usercontrol and that it comes
from the binding of selectedvalue. But am not understanding where beyond
that.


Dim sv As Object
<Bindable(True)> _
Public Property SelectedValue() As Object
Get
Return sv
End Get
Set(ByVal Value As Object)
sv = Value
If Not Me.DataViewer Is Nothing Then
If Me.DataViewer.Count > 0 And Not Me.fromkeypress And Not
Me.activateleave Then
Me.DataViewer.Sort = Me.ValueMember
Dim index As Integer = Me.DataViewer.Find(Value)
If index > -1 Then
Me.txBOX.Text =
Convert.ToString(Me.DataSource.Rows(index).Item(Me.DisplayMember))
Else
Me.txBOX.Text = Convert.ToString(Value)
End If
ElseIf Not Me.activateleave Then
Me.txBOX.Text = ""
End If
End If
End Set
End Property
 
need to add eventhandler for the bound object in this case

Public Event SelectedValueChanged As EventHandler

and raise that event when the is a change that will effect the bound table
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top