visual studio 2010 (vb.net window forms)
access 2010 database
multiple forms
tab controls (2 tabs)
groupboxes

I have a BindingSource bound to a single row of a dataset.table

The question is how to call and check the information of a single cell

the cells are bound to textbox.text however on load when i call for information for those on tabpage2, they don't seem to populate fast enough to call from form_Load.

I was wondering if there was a way to call they bound data directly from the biding source

for example:

Private Sub frmEditCust_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'AutoBillDataSet.Customer' table. You can move, or remove it, as needed.
        Me.CustomerTableAdapter.Fill(Me.AutoBillDataSet.Customer)
        'checks if Same Address is being used and checks box (this is on tabpage 1 and populates fine) 
        If txtBillTo.Text = txtLocation.Text And txtAttentTo.Text = txtAttention.Text And txtAddressTo.Text = txtAddr.Text And txtCityTo.Text = txtCity.Text And txtZipTo.Text = txtZip.Text And txtStateTo.Text = txtState.Text And mtbPhoneTo.Text = mtbPhone.Text Then
            cbSame.Checked = True
        End If
        'checks Billing cycle and chooses appropriate radio button (tabpage 2, first groupbox)
        Select Case txtBillingCycle.Text
            Case "Monthly"
                rbMonthly.Checked = True
            Case "Bi-Monthly"
                rbBiMonth.Checked = True
            Case "Quarterly"
                rbQuarter.Checked = True
            Case "Annually"
                rbAnnual.Checked = True
            Case "Bi-Annually"
                rbBiAnnual.Checked = True
        End Select
        
    End Sub

this does not populate the radiobutton for the billing cycle if a msgbox is placed before the select case statement I get a blank field but during afterwards the txtBillingCycle.text is populated

so i was wondering if there was a way to call on the bindingSource itself
something like

'checks Billing cycle and chooses appropriate radio button (tabpage 2, first groupbox)
        Select Case CustomerBindingSource.DataMember("Billing_Cycle").ToString
            Case "Monthly"
                rbMonthly.Checked = True
            Case "Bi-Monthly"
                rbBiMonth.Checked = True
            Case "Quarterly"
                rbQuarter.Checked = True
            Case "Annually"
                rbAnnual.Checked = True
            Case "Bi-Annually"
                rbBiAnnual.Checked = True
        End Select

anyone have any ideas

You might want to try BindingComplete event. Read here: http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.bindingcomplete.aspx

I tried this and while i can follow the logic it still doesnt work:

added:

Private WithEvents bBillCycle As Binding

to the form then on form_Load added:

bBillCycle = txtBillingCycle.DataBindings.Add("Text", CustomerBindingSource, "Billing_Cycle", True)

and finally added:

Public Sub bBillCycle_BindingComplete(ByVal sender As System.Object, ByVal e As BindingCompleteEventArgs) Handles bBillCycle.BindingComplete
        If Not e.BindingCompleteState = BindingCompleteState.Success Then
            MessageBox.Show("bBillCycle: " + e.ErrorText)
        End If
        Select Case txtBillingCycle.Text
            Case "Monthly"
                rbMonthly.Checked = True
            Case "Bi-Monthly"
                rbBiMonth.Checked = True
            Case "Quarterly"
                rbQuarter.Checked = True
            Case "Annually"
                rbAnnual.Checked = True
            Case "Bi-Annually"
                rbBiAnnual.Checked = True
        End Select
    End Sub

I get no error but still it does not populate a radiobutton like it should

I can use the code with a tabpage_Mouseclick and after changing tab i can click and it will work .

I can even set it up for it to work from a button but i can't seem to get it to do it automatically after or during form load

MSDN's example of the usage was to handle errors. That's why it is using If [B]NOT[/B] e.BindingCompleteState.... This means that if the binding didn't complete without errors (or errors came up during binding) then your cases will be evaluated. I think you need to remove the Not part and try again.

In this case of the code it should not matter as the Select Case Clause in not within the IF statement. I had left that in to make sure binding was completing. However, I did rem it out and still not affecting the tabpage. I cant seem to understand I can place the information on the first tab and just placing the code in the form_Load event and it will work.

I wonder if it is an issue using an tab control with multiple pages??

You are right, it shouldn't matter. I just now saw where you placed the end if.

As I don't have VB available right now to play around and get you a possible answer, perhaps you'd like to think about assigning the value on TabPage2.Enter event?

Follow up after some testing :

place textbox on tabpage one and bound to billing cycle
with visible set to false the binding source would not populate
with visible set to true populated by binding source.

using the tabpage2.enter did not work either

so ended up leaving txtbox on tabpage1 visible
and on page load convert textbox.text to string then made textbox.visible=false.

basically got the variable i wanted as a string to use and noone sees the textbox... works though there has to be a better way

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.