Jump to content
  • Advertisement
Sign in to follow this  

[.net] Untitled

This topic is 3942 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am a newb in Visual C++ Express Edition 2005. I am having trouble of saving treeView nodes into a TEXT file. For details, I will explain below: My application is a company data application. It consists of a treeView and a listView. Nodes of the treeView represent the company name and employee name only. So the treeView looks like this: -ALL -Microsoft -Robert -Tony -IBM -Johny -Apple -Gary It only store like that. The listView display all details of each person above. Company Name | Employee Name | Age |Gender | Address | City | ZIP | Phone ========================================================== Microsoft | Robert | 30 | Male | 1 ABC | Seattle | 64543 | 355135 Microsoft | Tony | 25 | Male | 1 DEF | Seattle | 64543 | 1343141 IBM | Johnny | 44 | Male | 1 XYZ | NY | 1235 | 355135 Apple | Gary | 23 | Male | 1 PQR | LA | 12344 | 363588 So it looks like that. The listView items will be saved to a text file with CSV format which are: Company name,employee name,age,gender,address,city,ZIP,phone So it is like this: Microsoft,Robert,30,Male,1 ABC,Seattle,64543,355135 Microsoft,Tony,25,Male,1 DEF,Seattle,64543,1343141 IBM,Johnny,44,Male,1 XYZ,NY,1235,355135 Apple,Gary,23,Male,1 PQR,LA,12344,363588 1. The PROBLEM is the treeView nodes MUST also saved to this file. How to do that? Or if anybody have ever tried this can I have the code copy? And how to load it when the application started? I have succeeded in saving and loading the listView items. 2. How to do this: If I click the company name on the treeView, for example Microsoft, then the listView will FILTER that ONLY Microsoft and its employee data will be shown up on the listView. If I click the employee name on the treeView, for example Gary, then only Gary's data will be shown up on the listView. If I click the root node (ALL) there is no FILTERING. How to do that? 3. If I delete the data on the listView then the node on the treeView will also be DELETED. I am having problem in searching the nodes of the treeView. I have tried this lines of code from the IDE Help, but it was error. It should have worked. Here is the code : private: void PrintRecursive( TreeNode^ treeNode ) { // Print the node. System:iagnostics:ebug::WriteLine( treeNode->Text ); MessageBox:how( treeNode->Text ); // Print each node recursively. System::Collections::IEnumerator^ myNodes = (safe_cast<System::Collections::IEnumerable^>(treeNode->Nodes))->GetEnumerator(); try { while ( myNodes->MoveNext() ) { TreeNode^ tn = safe_cast<TreeNode^>(myNodes->Current); PrintRecursive( tn ); } } finally { //IDisposable^ disposable = dynamic_cast<System::IDisposable^>(myNodes); //if ( disposable != nullptr ) //disposable->Dispose(); } } // Call the procedure using the TreeView. void CallRecursive( TreeView^ treeView ) { // Print each node recursively. TreeNodeCollection^ nodes = treeView->Nodes; System::Collections::IEnumerator^ myNodes = (safe_cast<System::Collections::IEnumerable^>(nodes))->GetEnumerator(); try { while ( myNodes->MoveNext() ) { TreeNode^ n = safe_cast<TreeNode^>(myNodes->Current); PrintRecursive( n ); } } finally { //IDisposable^ disposable = dynamic_cast<System::IDisposable^>(myNodes); //if ( disposable != nullptr ) // disposable->Dispose(); } } //***End of treeView iteration***// The ERROR was: c:\chris\19november2007-01.40am\assignment191107-0140\Form1.h(235) : error C2039: 'Dispose' : is not a member of 'System::IDisposable' c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : see declaration of 'System::IDisposable' You should invoke the destructor, '~IDisposable' instead The ERROR is at the block : finally { IDisposable^ disposable = dynamic_cast<System::IDisposable^>(myNodes); if ( disposable != nullptr ) disposable->Dispose(); } } I found out that the error was at this block but I didn't know how to fix it. Is it possible that someone fix this for me, please? What does "You should invoke the destructor, '~IDisposable' " mean? And how to do that? Thank you very much.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!