|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Databind TabControl as Detail to Master RecordsI have two tables. One is the master and the other is the detail. I am successfully binding them both and can successfully bind the detail to a datagrid and pull in all related detail records to the master. (not really what I want though) I have created a user control with the fields from the detail table and would like to dynamically create tabpages on my tabcontrol so there are as many tabs as there are detail records corresponding to the master record. I'm only pasting the code that creates the tabpage and I hope that is enough. The problem I have is that I need to figure out when / how to call this sub for every detail record. Private Sub AddTabPage() Dim tbPage As New TabPage Dim ctlMyPage As New CGAAppLibraryTabPage_ctl ctlMyPage.txtModDesc.DataBindings.Add("Text", dsAppMaster, "app_master.AppMod.mod_desc") ctlMyPage.txtModMigDoc.DataBindings.Add("Text", dsAppMaster, "app_master.AppMod.mod_migdoc") ctlMyPage.txtModSetup.DataBindings.Add("Text", dsAppMaster, "app_master.AppMod.mod_setup") ctlMyPage.cboModType.DataSource = dsAppMaster.app_types ctlMyPage.cboModType.SelectedItem = dsAppMaster.Tables("app_master.AppMod.mod_type") ctlMyPage.cboModType.DisplayMember = "app_type" tbPage.DataBindings.Add("Text", dsAppMaster, "app_master.AppMod.mod_name") tbPage.Controls.Add(ctlMyPage) TabControl1.TabPages.Add(tbPage) End Sub Any help or direction would be greatly appreciated. -- Cheryl (CGA) Cheryl,
I don't think that you can bind them in this case. If you bind them you bind the complete table and it will be showed depending the position in the bindingcontext. I think that you are better of with a routine like this. Remove on your tabcontrol all pages Create a dataview with as rowfilter your selection (the key from the master) loop through the dataviewrows and create pages as many as there are rows have an innerloop in that which creates dynamicly the fields and fill that To get the information back I would do the same loop. That is the way as I would try it. I hope this helps, Cor Show quote "Cheryl" <Che***@discussions.microsoft.com> schreef in bericht news:A569D892-97D3-48D8-814C-936D02FE3E70@microsoft.com... > Using VB.NET 2003. > I have two tables. One is the master and the other is the detail. I am > successfully binding them both and can successfully bind the detail to a > datagrid and pull in all related detail records to the master. (not really > what I want though) > > I have created a user control with the fields from the detail table and > would like to dynamically create tabpages on my tabcontrol so there are as > many tabs as there are detail records corresponding to the master record. > I'm > only pasting the code that creates the tabpage and I hope that is enough. > The > problem I have is that I need to figure out when / how to call this sub > for > every detail record. > > > Private Sub AddTabPage() > Dim tbPage As New TabPage > Dim ctlMyPage As New CGAAppLibraryTabPage_ctl > ctlMyPage.txtModDesc.DataBindings.Add("Text", dsAppMaster, > "app_master.AppMod.mod_desc") > ctlMyPage.txtModMigDoc.DataBindings.Add("Text", dsAppMaster, > "app_master.AppMod.mod_migdoc") > ctlMyPage.txtModSetup.DataBindings.Add("Text", dsAppMaster, > "app_master.AppMod.mod_setup") > ctlMyPage.cboModType.DataSource = dsAppMaster.app_types > ctlMyPage.cboModType.SelectedItem = > dsAppMaster.Tables("app_master.AppMod.mod_type") > ctlMyPage.cboModType.DisplayMember = "app_type" > tbPage.DataBindings.Add("Text", dsAppMaster, > "app_master.AppMod.mod_name") > tbPage.Controls.Add(ctlMyPage) > TabControl1.TabPages.Add(tbPage) > End Sub > > Any help or direction would be greatly appreciated. > -- > Cheryl (CGA) Cor,
Thanks for the response. I was afraid of that! I guess I know what I'll be doing today. I'll let you know how it turns out. Cheryl (CGA) Show quote "Cor Ligthert [MVP]" wrote: > Cheryl, > > I don't think that you can bind them in this case. If you bind them you bind > the complete table and it will be showed depending the position in the > bindingcontext. > > I think that you are better of with a routine like this. > > Remove on your tabcontrol all pages > Create a dataview with as rowfilter your selection (the key from the master) > loop through the dataviewrows and create pages as many as there are rows > have an innerloop in that which creates dynamicly the fields and fill > that > > To get the information back I would do the same loop. > > That is the way as I would try it. > > I hope this helps, > > Cor > > > > "Cheryl" <Che***@discussions.microsoft.com> schreef in bericht > news:A569D892-97D3-48D8-814C-936D02FE3E70@microsoft.com... > > Using VB.NET 2003. > > I have two tables. One is the master and the other is the detail. I am > > successfully binding them both and can successfully bind the detail to a > > datagrid and pull in all related detail records to the master. (not really > > what I want though) > > > > I have created a user control with the fields from the detail table and > > would like to dynamically create tabpages on my tabcontrol so there are as > > many tabs as there are detail records corresponding to the master record. > > I'm > > only pasting the code that creates the tabpage and I hope that is enough. > > The > > problem I have is that I need to figure out when / how to call this sub > > for > > every detail record. > > > > > > Private Sub AddTabPage() > > Dim tbPage As New TabPage > > Dim ctlMyPage As New CGAAppLibraryTabPage_ctl > > ctlMyPage.txtModDesc.DataBindings.Add("Text", dsAppMaster, > > "app_master.AppMod.mod_desc") > > ctlMyPage.txtModMigDoc.DataBindings.Add("Text", dsAppMaster, > > "app_master.AppMod.mod_migdoc") > > ctlMyPage.txtModSetup.DataBindings.Add("Text", dsAppMaster, > > "app_master.AppMod.mod_setup") > > ctlMyPage.cboModType.DataSource = dsAppMaster.app_types > > ctlMyPage.cboModType.SelectedItem = > > dsAppMaster.Tables("app_master.AppMod.mod_type") > > ctlMyPage.cboModType.DisplayMember = "app_type" > > tbPage.DataBindings.Add("Text", dsAppMaster, > > "app_master.AppMod.mod_name") > > tbPage.Controls.Add(ctlMyPage) > > TabControl1.TabPages.Add(tbPage) > > End Sub > > > > Any help or direction would be greatly appreciated. > > -- > > Cheryl (CGA) > > > |
|||||||||||||||||||||||