1. William Beale
  2. PowerBuilder
  3. Sunday, 23 May 2021 06:34 AM UTC

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

 

 

Accepted Answer
Arthur Hefti Accepted Answer Pending Moderation
  1. Sunday, 23 May 2021 06:56 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi

when I got your question right, you can do:

   THIS.tab_entry.SelectTab( li_count )

after of_add_new_entry()

Regards
Arthur

Comment
  1. William Beale
  2. Sunday, 23 May 2021 08:11 AM UTC
Many Thanks Arthur - worked fine.
  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 24 May 2021 09:15 AM UTC
Just a tip:

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.
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.