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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controls Lose Data

Status
Not open for further replies.

baugie

Programmer
Apr 9, 2003
56
US
I am using two forms to display data. The first form allows for searching and viewing key fields. There exists a treeview and two listviews. When the user selects a specific record from a listview a second form opens showing the details.

When moving from the search form, I am simply hiding it using the Hide method (tested with visible property also). When the user is done with the Detail form I use the Show method to show the search form again. However, the data loaded into the treeview and listviews is missing. When I repeat the process for a second time (without closing the search form), the data remains when I return to the search screen. So it only disappears the first time I hide the form and keeps it all other times. If I close the form and start over, it repeats the same problem (missing 1st time, present there after).

I have never had this problem before...any ideas?

I am using VB6(SP5) on WinXP

Thanks in advance

baugie
 
Loading the data to the search form?

- using ado recordset to add items to the treeview and to build arrays, using arrays to load data into listviews

Loading data to the detail form?

- using ado recordset to load data to controls


Losing data on the treeview and listviews during the first Hide method call, saves it on all subsequent calls

thanks for quick response
 
Update to the problem...

The first time the search form loses focus, the form load event kicks off when it receives focus again. However, it does not run every time after that. The form is still in the forms collection so it isn't being unloaded. Why is the Form Load event kicking off when it receives a Show or Visible = True, and why does it only run the first time it receives focus?

Thanks!

a perplexed baugie
 
Further update;

The load event kicked off the first time because it was actually loading a new instance of the search form. It seems to lose reference to the form when it is hidden so it opens up a new instance of it. However, each time the form is hidden afterwards, it does not lose reference to it so it makes the new one visible. This was very odd.

So now when setting a form visible again, I now loop through the forms collection to find the correct form to show. This seems to work ok, but doesn't seem as though I should have to do this just to hide and show a form.

Any information anybody has on why this is happening I would love to hear it.

Thanks

baugie

[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top