Is it possible to bind a listbox to a child table so that it will only display the child records based on the current parent record?
[quoted text, click to view] Bart Mermuys wrote: > Hi, > > <rwwagner@geodecisions.com> wrote in message > news:1163541892.230513.277920@b28g2000cwb.googlegroups.com... > > Is it possible to bind a listbox to a child table so that it will only > > display the child records based on the current parent record? > > > > Yes it is. But how you would do it depends on which framework you are using > 1.1 or 2.0, whether you want to do this using the designer or from code. Do > you already have the parent and child DataTable loaded, is there already a > DataRelations between them, etc. > > HTH, > Greetings
Thanks for you help. I'm using 1.1 and I already have the tables loaded with the datarelation. I'm using a strongly-typed dataset. I would like to do this in code. Bob
[quoted text, click to view] Bart Mermuys wrote: > Hi, > > <rwwagner@geodecisions.com> wrote in message > news:1163541892.230513.277920@b28g2000cwb.googlegroups.com... > > Is it possible to bind a listbox to a child table so that it will only > > display the child records based on the current parent record? > > > > Yes it is. But how you would do it depends on which framework you are using > 1.1 or 2.0, whether you want to do this using the designer or from code. Do > you already have the parent and child DataTable loaded, is there already a > DataRelations between them, etc. > > HTH, > Greetings
Thanks for you help. I'm using 1.1 and I already have the tables loaded with the datarelation. I'm using a strongly-typed dataset. I would like to do this in code. Bob
Bart, I'm still having issues. Here is what I have. This is in vb by the way... childListBox.DataSource = yourDataSet childListBox.DisplayMember = "SomeParentTable.YourParentToChildRelation.SomeTextField" childlistBox.ValueMember = "SomeParentTable.YourParentToChildRelation.SomeTextField" I also have currency managers defined: cmParent = Me.BindingContext(myDataSet, "ParentTable") cmChild = Me.BindingContext(muDataSet, ""ParentTable.YourParentToChildRelation") What I get displayed in the list box is the text "System.Data.DataViewManager" any ideas? Thanks
Hi, [quoted text, click to view] <rwwagner@geodecisions.com> wrote in message news:1163541892.230513.277920@b28g2000cwb.googlegroups.com... > Is it possible to bind a listbox to a child table so that it will only > display the child records based on the current parent record? >
Yes it is. But how you would do it depends on which framework you are using 1.1 or 2.0, whether you want to do this using the designer or from code. Do you already have the parent and child DataTable loaded, is there already a DataRelations between them, etc. HTH, Greetings
Hi, [quoted text, click to view] <rwwagner@geodecisions.com> wrote in message news:1163596805.725415.223310@h48g2000cwc.googlegroups.com... > > Bart Mermuys wrote: >> Hi, >> >> <rwwagner@geodecisions.com> wrote in message >> news:1163541892.230513.277920@b28g2000cwb.googlegroups.com... >> > Is it possible to bind a listbox to a child table so that it will only >> > display the child records based on the current parent record? >> > >> >> Yes it is. But how you would do it depends on which framework you are >> using >> 1.1 or 2.0, whether you want to do this using the designer or from code. >> Do >> you already have the parent and child DataTable loaded, is there already >> a >> DataRelations between them, etc. >> >> HTH, >> Greetings > > > Thanks for you help. I'm using 1.1 and I already have the tables > loaded with the datarelation. I'm using a strongly-typed dataset. I > would like to do this in code.
If you have all that, then it's just a matter of binding correctly, eg. : // parent SomeTextBox.DataBindings.Add("Text", yourDataSet, "SomeParentTable.SomeTextField"); // child listbox childListBox.DataSource = yourDataSet; childListBox.DisplayMember = "SomeParentTable.YourParentToChildRelation.SomeTextField"; HTH, Greetings [quoted text, click to view] > > Bob >
Hi, [quoted text, click to view] <rwwagner@geodecisions.com> wrote in message news:1163615451.947794.28150@m73g2000cwd.googlegroups.com... > Bart, > > I'm still having issues. Here is what I have. This is in vb by the > way... > > > childListBox.DataSource = yourDataSet > childListBox.DisplayMember = > "SomeParentTable.YourParentToChildRelation.SomeTextField" > childlistBox.ValueMember = > "SomeParentTable.YourParentToChildRelation.SomeTextField" > > I also have currency managers defined: > > cmParent = Me.BindingContext(myDataSet, "ParentTable") > cmChild = Me.BindingContext(muDataSet, > ""ParentTable.YourParentToChildRelation") > > > What I get displayed in the list box is the text > "System.Data.DataViewManager" > > any ideas?
Not many. This is usually an indication that ComboBox.DisplayMember hasn't been set, but i assume you did set it, so i don't know what's wrong. I did try a simple test app using the same code and it did work. Maybe you can post more code or the entire Form code if it isn't that big.... HTH, Greetings [quoted text, click to view] > > Thanks >
Bart, Below is my code. I set up a simple form to test this and it still doesn't work properly. Maybe you can see something that I am doing wrong. The people table will have multiple people returned. When I change the cmPeople.position property the form correctly displays the first and last name of the person. ' strongly typed dataset with people table (parent), id_numbers (child) table and relation (peopleid_numbers) defined between the two Dim peopleDS As New DataLayer.PeopleDS ' class that loads data into dataset - datatables Dim PeopleDA As DataLayer.PeopleDA Dim cmPeople As CurrencyManager Dim cmIDNumbers As CurrencyManager ' load data into dataset PeopleDA = New DataLayer.PeopleDA(people) PeopleDA.GetPeopleByCaseKey(10) cmPeople = Me.BindingContext(peopleDS, "PEOPLE") cmPeople.Position = 0 cmIDNumbers = Me.BindingContext(peopleDS, "PEOPLE.PEOPLEID_NUMBERS") cmIDNumbers.Position = 0 Me.TextBox1.DataBindings.Add("Text", peopleDS, "people.lname") Me.TextBox2.DataBindings.Add("Text", peopleDS, "people.fname") Me.ListBox1.ValueMember = "PEOPLE.PEOPLEID_NUMBERS.idnumkey" Me.ListBox1.DisplayMember = "PEOPLE.PEOPLEID_NUMBERS.idnumber" Me.ListBox1.DataSource = peopleDS I appreciate all of your help.... Bob
Hi Bart, You example worked for me once I found a stupid typo that I had in my code. Thanks for your help.... Bob
Hi Bart, Your example worked for me once I found a stupid typo that I had in my code. Thanks for your help.... Bob
Hi, [quoted text, click to view] <rwwagner@geodecisions.com> wrote in message news:1163697811.278043.188970@f16g2000cwb.googlegroups.com... > Hi Bart, > > Your example worked for me once I found a stupid typo that I had in my > code.
Glad you found the problem. [quoted text, click to view] > Thanks for your help....
You're welcome. Greetings [quoted text, click to view] > > Bob >
Don't see what you're looking for? Try a search.
|