Is this a VS Bug?

Arg81

Well-known member
Joined
Mar 11, 2005
Messages
949
Location
Midlands, UK
Programming Experience
1-3
Kinda down the lines of something I posted a while ago, and I don't see what's causing this problem.

Form:
User selects a customer. Clicks on SELECT, this pops up a model customer select form. customer name and customer ID are saved as a variable and the customer select form is closed.
The customer name is then put into the label to display the selection, and the customer ID is put into a textbox hidden behind the name.

The Customer Contact dataTable is then filled using the ID value, and the names display in the contact combobox.

The code for this is:
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] frm [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] frmCustomerSelect[/SIZE]
[SIZE=2]frm.ShowDialog()[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].lblCustomerName.Text = varCustomerSiteName[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].lblSiteID.Text = varSiteID[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].lblCustomerID.Text = varCustomerID[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].CustomerContactTableAdapter.FillByCustomerID([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].DsCustomerDetails.CustomerContact, [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].lblCustomerID.Text)[/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].cboCustomerContact.Focus()[/SIZE]

Now, the names display. 7/10 times the customer will only have 1 contact, so the contact name isn't changed.
By doing this, the "Value" of that row isn't copied to the main table column "selected value" with the rest of the data of the form

Is this a bug in VS, or is there a line of code I can add so it will force the row in the combobox to update or something like that?!?

If the user selects another contact, or if they reselect the same contact, it's fine - the problem only exists if the user doesn't actually choose someone from the combobox list.

The only way I can see of doing it is to call

Me.CustomerContactTableAdapter.FillByCustomerID(Me.DsCustomerDetails.CustomerContact, Me.lblCustomerID.Text)

when the contact CBO is entered....
 
haha...urm how to explain it easier :/

The combo box displays data from a dataTable that is filled when a Customer has been selected.

When the data is filled, the combobox shows the first contact name in the dataTable.

If the user doesn't need to change that name, they move onto the next field.

When this happens and they submit, the field CustomerContactID in my parent table is null. - the Value member (CustomerContactID) of the row shown in the combobox isn't actually copied over.

However, if the user enters the combobox and either
a) selects another contact or
b) reselects the first contact

then the customerContactID is shown in the parent table.

Is that better? :D


PS - name changed :p
 
Last edited:
and the selectedvalue databinding of the combobox is definitely bound to the same bindingsource that the rest of the data components bind through, isnt it? What is the combo's data source and member? what other properties are bound to data? what datatables, bindingsources and data bound controls exist on this form?

I'm still having difficulty picturing what is going on..
 
Yep, see screenshot.

There are other DT's and BS's on the form - see 2nd Screenshot!

With the Account Manager, Requested By and Ship By comboboxes, I use .selectedindex = -1 when the form loads so that they blank out. Therefore the user has to pick one, even if it's first person in individual comboboxes.

I've taken that approach with this, and forced the user to have to select someone from the contact list - i.e.

Me.CustomerContactTableAdapter.FillByCustomerID(Me.DsCustomerDetails.CustomerContact, Me.lblCustomerID.Text)
Me.cboCustomerContact.SelectedIndex = -1

and that fixes the issue...

Still think it's strange that if you don't select an item from the combobox because you want the value it displays when filled, it doesn't copy the SelectedValue to the main table....
 

Attachments

  • Image2.jpg
    Image2.jpg
    95.1 KB · Views: 25
  • Image3.jpg
    Image3.jpg
    46.3 KB · Views: 25
Back
Top