Hi,
I have code in a window function to add data in a new row in a datawindow on a tab page on the window.
Once the new entry is populated via the function (which works fine), I want to open that tab page from the calling function in the window.
Below is the code I use to call the function, so I have a ‘handle’ on the tab page but I don’t know how to code to open the tab page and make it active for the User:
li_upper = UpperBound(THIS.tab_entry.Control[])
FOR li_count = 1 to li_upper
If THIS.tab_entry.Control[li_count].classname() = 'u_tabpg_to_do' then
li_rc = THIS.tab_entry.Control[li_count].DYNAMIC of_add_new_entry(as_selected_text)
EXIT
End if
NEXT
// Code needed here in the function to open the tab page
Instead of doing
this.tab_entry.SelectTab(li_count)
do:
this.tab_entry.SelectTab( u_tabpage_xxxx ).
By using the control's name instead of the number, you avoid problems in the future: If ever a new tabpage is inserted before the tabpage that your are selecting now by number, or if someone decides that an existing tabpage now has to move before another one, then you'd have to go through all the code that selects tabs by using numbers, as the numbers have changed.
I found this problem myself in our code and had to modify 100's of lines of code any time my manager wanted to change anything until I decided that was enough and modified them all to use the tabpage control's names instead.
Also, I'm using ancestor classes for my tabs and tabpages in which I record "newpage", "oldpage" and currentpage in instance variables, so I can avoid having to ever ask if the selectedTabpage is some tabpage identifying it by its number.
If anyone is interested, I have this based on PFC classes.
regards.