| Hyderabad Jobs | Book Website | ![]() |
I Love Hyderabad | Hyderabad Colleges |
| Home | Business Emails | Hyderabad Classifieds | Contact Us | |
| 7 Wonders of Hyderabad | Web Hosting | Yellow Pages | Our Network | |
Mastering PowerBuilder
Using Independent Controls For Each Tab PageIn the previous example we used same DataWindow control for all tab pages. In this section let's learn how to use independent DataWindow controls on each tab page. Create another window 'w_tab_demo2' and add a new tab control to the window. Change the text of the first tab from 'none' to 'Receipts. Name this tab page as 'tabpage_receipts'. Place a DataWindow control on the 'tabpage_receipts'. Name the DataWindow control as 'dw_receitps'. Now, insert a new tab page and name it as 'tabpage_issues'. Change its text to 'Issues'. Place a DataWindow control on the 'tabpage_issues' and name the DataWindow control as 'dw_issues'. Similarly insert one more tab page for 'Returns'. We are using three DataWindow controls but, we haven't created/assigned DataWindow objects to these DataWindow controls. Paint a DataWindow to retrieve all the receipt transactions and assign that DataWindow object to the 'dw_receipts' DataWindow. That means, the data source for the DataWindow would be:
Similarly paint DataWindow objects for other DataWindow controls and assign them to the appropriate DataWindow controls. Then write the following code to the 'SelectionChanged' event of the 'tab_1' tab control.
You can observe that, in the third line we are using Control[] twice. The first control[] has the list of all the tab pages in the tab control. The second Control[] has the list of all controls that you placed on that tab page. As you know, we placed only one control i.e, DataWindow control on the tab page, That's why, I hard coded Control[1]. In real-world projects, you need to check whether that control is a DataWindow control or not and retrieve it only if it is a DataWindow control. The following revised code does that.
You can observe one more technique from the code fragments above. That is, we are checking whether the DataWindow has a transaction object set to it or not. If not, then only we are calling the SetTransObject() function. Now, to really understand the difference between 'Using a single control on all tab pages' and this method, you need to print the codes and compare them. In the former, we are referring to the DataWindow control directly like any other control on the window. However, we need to go an extra mile to find the correct DataWindow control in the tab page.
|
| Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com |