BindingSource not binding controls

R

Ryan

I have user defined control that accepts a data source to do some
custom data binding. When I bind the controls against the
bindingsource, it doesn't work, but if i bind it directly against
datatable object (Dim src), it works just fine. Issue is that using
BindingSource makes it easier to navigate through the bind. In
debugging, I see the correct data in the DataSource property so what
gives?

Private m_bindingSource As BindingSource


Public Property DataSource() As Object Implements
ISignBoardControl.DataSource
Get
Return m_bindingSource.DataSource
End Get
Set(ByVal value As Object)
If value.GetType IsNot
GetType(SignBoard.DataWS.Production) Then
Throw New ArgumentException("Incompatible data source
type")
Return
End If
' Dim src as DataWS.Production.PlanActual = value
(actual
datatable object)
m_bindingSource = New BindingSource(value, "PlanActual")
m_bindingSource.Position = 0
lblHeader.DataBindings.Add("Text", m_bindingSource,
"Part")
lblPlan.DataBindings.Add("Text", m_bindingSource, "Plan")
lblActual.DataBindings.Add("Text", m_bindingSource,
"Actual")
lblEfficiency.DataBindings.Add("Text", m_bindingSource,
"Efficiency")


Dim threadProc As Thread = New Thread(AddressOf
DisplayRecord)
threadProc.Name = "DisplayRecord"
threadProc.IsBackground = True
threadProc.Start()
End Set
End Property


' I use this function to iterate through each available row
Private Sub DisplayRecord()
Const timeout As Integer = 60000
While (Not stopThread)
Try
If m_bindingSource.Count = 0 Then Exit Try
If m_bindingSource.Position < m_bindingSource.Count -
1 Then
m_bindingSource.MoveNext()
Else
m_bindingSource.MoveFirst()
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
Thread.Sleep(timeout)
End While
End Sub
 
R

RobinS

I don't see where you are setting

m_bindingSource.DataSource = src

Is it just not here, or did you forget to set the data source for the
bindingSource?

RobinS.
GoldMail, Inc.
 

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

Top