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

Tree Control Problem.. Interesting

Status
Not open for further replies.

ronnyjljr

IS-IT--Management
Nov 23, 2003
249
US
Hello,

Ok here goes, I allow a user to insert an item in to a tree. Works Great. I allow them to delete the item. Works Great. When they go an try to insert a new item after deleting an item, the item text will not show up. If you click in the white area where the item is supposed to be, an area about 1/4th the size of the normal highlighted area is highlighted. However, if there is more than one item already in the tree when they delete an item, they can insert with no problem. What gives?

This is how I am inserting the item:
[blue]HTREEITEM NewItem = MyTree.InsertItem(TVIF_TEXT,myName,0,0,0,0,0,TVI_ROOT,NULL);[/blue]

And then I insert child items into the tree with:
[blue]MyTree.InsertItem("Blah",NewItem,TVI_SORT);[/blue]

And this is how I am deleting it:

[red]mySelectedItem = myTree.GetSelectedItem();
myRoot = myTree.GetParentItem(mySelectedItem);
myTree.DeleteItem(myRoot);
[/red]


I believe it is the way I am deleting it when there is only one item in the tree. Any thoughts?

Thanks,
Ron


/**************
Me: When will the project be finished?
Them: What project?
Me: The one you have been working on for the last 3 years!
Them: Ohh, we can't finish it?
Me: Why?
Them: We don't know how to program...
 
I do not get it. Why do you do

myTree.DeleteItem(myRoot);

Shouldn't you do ?

myTree.DeleteItem(mySelectedItem);

You are deleting the root instead of the item. I think this is your problem, though I have not worked so much with trees

HTH,

s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
This is how it goes..

I have a root item, with 5 or 6 child items underneath it. Everytime the user inserts a new item, it is inserted as a new root item.

If the user selects a child item and selects delete, I force them to delete the root. That is why the root is being deleted.

-Ron

/**************
Me: When will the project be finished?
Them: What project?
Me: The one you have been working on for the last 3 years!
Them: Ohh, we can't finish it?
Me: Why?
Them: We don't know how to program...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top