Show details based on selection above

MartinaL

Active member
Joined
Jun 13, 2006
Messages
30
Programming Experience
1-3
I have a windows form in the VB.Net Windows application that shows a persons details and their Next of Kin details.

You can scroll through the people using a binding navigator. You can also scroll through the next of kin details using a binding navigator.

What I want is to have the results that you can scroll through for the NOK only show the ones that are related to the person current selected/shown on the form.

also when you click no the + button to add a new NOK it should add for the currently selected person.

I have attached a screen shot of what I mean.

How do I do this?
 

Attachments

  • screen.jpg
    screen.jpg
    109.7 KB · Views: 22
What you discuss is a standard master-detail relationship. In my signature, click the Walkthroughs 2.0 link and read "Displaying related data" topics
 
Note; your form appears to have way too many data related objects for what I would expect of a form like you have shown here. I'd expect:
A DataSet (it contains all the datatables)
BindingNavigators for NOK and Personal
BindingSources for NOK and personals
TableAdapters for NOK and personals..

The other stuff I'm guessing is to do with your dropdowns, state etc.. I must admit I normally do those in code, after creating a single public instance (in a module) of a datatable holding e.g. all my State data - It isnt going to change much so I dont upload/download it ever time the form is opened, only when the app starts
 
Thanks to the tutorial I now have it working fine.

But, you suggestion about the dropdowns for states, units and relationships is a good one, any tutorials on how to set that up?
 
I can only tell of how i do it:

One module in my app is concerned with tables that hold lookup values (State, Unit, Regiment, Salutation, Gender, Ethnic Origin etc) and also with preferences like user's preferred background colours, language etc

This module has a Sub called RefreshLUTs() that refreshes the lookup tables.

All my lookup tables go in one DataSet - the LookupDataSet.

The module makes an public instance of this dataset:
VB.NET:
Public Module Universe
  Public Constant lookupDS as New LookupDataSet
and one instance of each TableAdapter for the tables in the set.

Each table in the set is filled by the call to RefreshLUTs and hence I can re-call this at any point (and I do, after one form in my app that maintains the LUTs is used to edit them) and get the updated values

On a form, for a combobox, I will still use the visual designer to bind SelectedValue to the relevant table in question, and then the constructor code I do:

VB.NET:
GenderCombo.DataSource = Universe.lookupDS.GenderDataTable
GenderCombo.DisplayMember = "GenderDisp"
GenderCombo.ValueMember = "GenderVal"


I'd be interested to see if this causes you any issues on forms where the same source LUT is used for more than one combo - i.e. on your form you have states in there twice. I'd love to know if changing one affects the other. It shouldnt, but it may if the bindingcontexts are the same. If that's the case, its simple to sort, I just always wondered if it was necessary
 
Back
Top