Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need code to read data from text file and display the data in Tree Control...With a condition if, the text in the file not preceded by tab, it should be in parent node and if preceded by tab, it should be in child node.

Example: Notepad contains two lines.....
Hello -> (not preceded by tab space)
World -> (preceded by tab space)

Then when we run our app, the tree should display "Hello" in parent node and "world" in child node.

Thank you.

What I have tried:

Any kind help would be lifesaver!
Posted
Updated 17-Dec-18 23:06pm

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
 
Share this answer
 
Comments
rmdsagar 19-Dec-18 0:59am    
Thank you, Richard! That's a start and found a way to write a code to display data in tree. I'm wondering how to read the co-ordinate or position of the text in the file. I need to read the position in order to design tree.
Richard MacCutchan 19-Dec-18 3:07am    
It is not reading the file that is the issue, but how you interpret the data. You need to parse each line as you read it and check the number of tabs in front of the text. That will tell you whether the entry is a main or child node of the tree.
rmdsagar 19-Dec-18 3:21am    
Exactly! So here I'm parsing each line as I read:
while(file.ReadString(iText, 99))
{ }
now, how to check the number of tabs in front of the text. Is there any dedicated method in MFC? please gimme some headsup
Richard MacCutchan 19-Dec-18 3:30am    
You have to look at each character of the text you read. I don't know of any ready made class specific to this problem, but I would guess that CString is worth looking at.
Richard MacCutchan 19-Dec-18 3:32am    
I just noticed that you appear to have two accounts, this one, and dhaya sagar - Professional Profile[^]. You should use a single account, and close the unused one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900