[dba-VB] Open a filtered form

Michael Maddison michael at ddisolutions.com.au
Tue Dec 11 19:51:23 CST 2007


Hi John,

Is this what you are looking for?  I've done the sample as a parent
child and used the absolute minimum of code. (4 lines C#)


1.  Create blank project
2.  Use menu to add Dataset, call it Orders.  Project --> Add Class
select Dataset from available items.
3.  In Server Explorer add a OLEDB connection to Northwind.
4.  Drag the Customers, Orders and the Order Details tables onto
Orders.xsd (Dataset).
If you want read only data then you can right click on the
OrdersTableAdapter, Configure, Advanced, untick Generate Insert...etc
5.  Save.
6.  Go to form1, add DataSet from Toolbox, select Typed dataset from
dialog, you should see the Dataset you just created. OK
7.  Add 3 text boxes and a combo box to the form1.
8.  Add a BindingSource to the form, select Orders1 as the datasource,
Orders as the DataMember.
9.  Add a BindingNavigator, set the BindingSource to BindingSource1.
10  Bind each of the textboxes.  
Select the textbox, in the properties window open the DataBindings Node.
Click advanced, Binding: select bindingSource1 - OrderID
Do the same for the other textboxes, notice the formatting options.
11. Add another BindingSource to form1, DataSource = orders1, DataMember
= Customers
12. Binding the Combo.  *Different to textbox...
>From Combo properties select DataSource - bindingSource2
Go to the code view, in the Form1_Load event add...

            comboBox1.DataSource = this.bindingSource2;
            comboBox1.DisplayMember = "CompanyName";
            comboBox1.ValueMember = "CustomerID";

            comboBox1.DataBindings.Add( "SelectedValue",
this.bindingSource1, "CustomerID" );

This completes the parent part of the form.
Run the app.

Child records will be shown in the DataGridView.

1.  Add DataGridView to form.
2.  Properties, DataSource, Drill into bindingSource1 and select order
details  (ordersOrderDetailsBindingSource).

Done!

Run the app.

cheers

Michael M

Someone here must be opening forms filtered down to a set of records?  I
need to select a record in a main form and then open another form
filtered to records related to the main form.  The equivalent of the
popup filtered forms from Access.

Can anyone show code to cause this to happen?  

Let's assume for the moment a grid control in the popup form.

I assume code in the form will create a data set object and bind the
grid to that.  I don't want the whole table though, I only want a set of
records, a WHERE.  And if I enter records I need the PKID from the
parent table automagically entered in the new records I am creating.
And I don't want the FK field from the parent object displayed in the
grid.

You know, "just like Access does it", and of course "just like you would
logically expect it to be done".

Is anyone doing this stuff?

John W. Colby
Colby Consulting
www.ColbyConsulting.com 

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com





More information about the dba-VB mailing list