Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2008

Tip: Looking for answers? Try searching our database.

BindingSource not binding controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ryan - 11 Jan 2008 17:18 GMT
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
RobinS - 12 Jan 2008 05:38 GMT
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.
------------------------------
>I have user defined control that accepts a data source to do some
> custom data binding.  When I bind the controls against the
[quoted text clipped - 57 lines]
>        End While
>    End Sub

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.