vb 2005 binding source to object

jvcoach23

Centurion
Joined
May 22, 2003
Messages
192
Location
Saybrook, IL
i have a class that I've tried to make into a datasource with the wizard. when I do a debug.writeline and step through the each row in the

ex:

For Each oemail In oEmails

Debug.WriteLine(oemail.EmailAddress)

Next

i see my 27 rows of data. however, when I drag the "Email" datasource as a datagridview to my form.. the data isn't showing up in the grid. What am I not doing that the two are not wired together. I looked in my EmailBindingSource and it says that the datasource is Email... but it's still not working..

also.. when I drop the datasource on the form... no lines of code are added.. I don't know there there are suppose to be any.. but figured I'd mention it. Seems to me there should be something... otherwise how does it know to grab the data from the datasource object after the object is laoded up

What it did add to the design is a BindingSource and a BindingNavigator.
any help would be great.
thanks
shannon
 
If you had the code/project to post that might help.

This is really new waters. I'm not sure how many people have taken the jump to 2005 yet.

Based on what you're saying, I can't see anything wrong - but maybe a sample project with the problem might help.
 
i got it figured out. there is pluming that has to go on.. Here is the line of code that was needed.

Visual Basic:
Me.EmailsBindingSource.DataSource = oEmails

I had tried that before.. but was trying to have a datasource = Emails.. which was my class... instead of going after what had been instantiated.. think that is the right term.. anyway... here is what the complete code looks like

Visual Basic:
Public Class frmMain


    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim oemail As asr.Email
        Dim oEmails As New asr.Emails

        With oEmails
            .sEmail = "steve"
            .LoadFromDb()
            oEmails = .Load("")
        End With
        For Each oemail In oEmails
            Debug.WriteLine(oemail.EmailAddress)
        Next

        Me.EmailsBindingSource.DataSource = oEmails

    End Sub

wow.. glad i got past this one.. on to the next one..
thanks
shannon

Denaes said:
If you had the code/project to post that might help.

This is really new waters. I'm not sure how many people have taken the jump to 2005 yet.

Based on what you're saying, I can't see anything wrong - but maybe a sample project with the problem might help.
 
Back
Top