Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TreeViewItem - Selection/FindItem Not Working?

Status
Not open for further replies.

kaul125

Programmer
Jan 29, 2002
87
US
I have a userobject that has multiple controls on it, one of them being a treeviewitem. Lets call this userobject, u_patient_controls. I've inserted this userobject on a tabobject, called u_patient_tab. The u_patient_tab is then put on a window.

The tabobject consists of 26 tabs, 1 for each letter of the alphabet. I have a function on u_patient_controls called of_search(). The purpose of this function, is to select the tab and patient name the user enters from a popup window. The problem I'm having is when it is looping through the treeviewitems it always searches the items in the first tabpage, which is tabpage_a. For example, if tabpage_a is currently selected and the user enters a name that begins with 'N', after the use clicks 'OK' on the popup window, I want to select tabpage_n and loop through the treeviewitem on that tabpage to find the patient. Here is the code in the of_search():

variable declaration.......

//Select the tab associated with the patients last name
lt_tab1 = This.GetParent()
For li_loop = 1 to UpperBound(lt_tab1.Control[])
If lt_tab1.Control[li_loop].Text = ls_last_name then
lt_tab1.SelectTab(li_loop)
exit
end if
next

userobject tp_1
//select the tabpage
tp_1 = lt_tab1.control[li_loop]
tv_patients.SetFocus()
// find the Root Item
ll_root_handle = tv_patients.finditem(RootTreeItem!,0)
// Traverse thru the consequative Items
ll_handle = tv_patients.finditem(ChildTreeItem!,ll_root_handle)
// loop till found
tv_patients.getitem(ll_handle,ltvi)
if ltvi.Data = li_paptrac_number then
tv_patients.selectitem(ll_handle)
else
do while ll_handle <> -1
ll_next_handle = tv_patients.finditem(NextTreeItem!,ll_handle)
tv_patients.getitem(ll_next_handle,ltvi)
if ltvi.data = li_paptrac_number then
tv_patients.selectitem(ll_next_handle)
exit;
else
ll_handle = ll_next_handle
end if
loop
end if

How can I loop through the treeviewitems of the currently selected tab, which under my exaple should be tabpage_n?

Keith
 
Hi,

I think that ur earlier problem of accessing objects on a tabpage seems to have been solved. (I had misplaced my password - so was responding to ur problem as visitor).

In the present code, I am not able to figure out a few things - where is tv_patients coming from. Is this a single control on the tab object or one control on each tabpage - if one on each tabpage then you will have to get the proper handle (in terms of assigning it to a variable) before u can refer to it. If u can explain it a bit more, then maybe I will be able to provide some help

Regards
RTewari
 
Yes, my earlier problem has been solved and thanks for the input.

As for the current problem, the treeview control, tv_patients, is located on the user object u_patient_controls. Then the u_patient_controls is inserted into the tab userobject, called u_patient_tab. So, for each tabpage on the tab control userobject I've inserted the u_patient_tab.

Let me know if you need further information/explaination.

Keith
 
Your current problem is similar to your earlier problem of accessing objects dynamically.

In your code so far you have been able to dynamically get the reference to the tabpage you want to access - tp_1 as I can see from the code. Now you will need to get the reference to the treeview on this tabpage similarly.

I assmue you have already defined a class userobject (i.e. in some pbl) as u_patient_tab which contains another userobject u_patient_controls which contains the treeview control tv_patients. So when you are looping through the control array in the tab object,

instead of

userobject tp_1
//select the tabpage
tp_1 = lt_tab1.control[li_loop]
......

write the code as

u_patient_tab tp_1
//select the tabpage
tp_1 = lt_tab1.control[li_loop]
........

then you can refer to the treeview control as

tp_1.u_patient_controls.tv_patients

As of now, in your code, tv_patients is not getting linked to the specific tabpage - so probably the problem.

I hope it helps.

RTEWARI


 
After changing my code to your suggestion, I'm getting a compile error. Also, I might be confused as to how I access userobjects on tabcontrols.

First of all, the compile error I'm getting on 'tp_1 = lt_tab1.control[li_loop]' is:

Incompatible types in assignment: u_patient_tab, userobject

If you look back at my first post in this thread, I did not mention the datatype for the declaration of lt_tab1. I've declared it as follows:

tab lt_tab1

I've also declared it as follows and received similar compile errors:

userobject lt_tab1 or u_patient_tab lt_tab1

If you again look back at my first post in this thread, the 'for' loop actually works. It does reference the right tabpage. So, after implementing your last suggestion, I'm confused as to why I'm getting the compile error.

If lt_tab1.control[li_loop] references the tabcontrol and the tabpage, why can't I just reference the tv_patient directly? Would you like a copy of the objects so you can look at the code?

Thanks for helping!!!

Keith
 
I got confused a bit.

u_patient_tab is a tab object and not a tabpage object. Is u_patient_controls a tabpage object? If yes, then in the suggested change,

instead of

u_patient_tab tp_1
.....

write the code as
u_patient_controls tp_1
.....

Otherwise, send me the objects and I can have a look at the code also (rajeshwart@niit.com).

RTEWARI
 
You are correct in saying u_patient_tab is a tab object. However, u_patient_controls is a userobject not a tabpage object.

I will send you the objects shortly.

Thanks for your help!

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top