Treeview - getting the selected branch

Discussion in 'Questions (Windows Mobile)' started by blackbox, Nov 22, 2008.

  1. blackbox

    blackbox New Member


    I have a tv control that has different branches for different tables in a relational db.
    I wish to be able to select any node and then enter a new child value that will also populate the underlying table. The question is, how do I identify which branch is selected and which underlying table that is from.

    For example, If I select 'Manufacturer' and then type a new entry (Ford) into a text box, I want that entry to go into tblManufactures which will be reflected when the TV is refreshed, If I then select Ford and add a new entry then I wish for the entry to go into tblCars,but also to trap the primary key from the Ford record to keep the data related.

    ------Mr Blonde
    ------Mr Brown

    How can I do this?

    Last edited: Nov 22, 2008
  2. specci48

    specci48 Well-Known Member Licensed User

    Hello blackbox,

    i took the treeview example from the help file and added a simple textbox to add a new node to the current selected node.

    If you want to implement much more features to manipulate the treeview (e.g. deleting or moving nodes) you may have a look at my ToDoTree application I posted here some time ago.


    Attached Files:

  3. blackbox

    blackbox New Member

    Thanks specci48

    Your app is great and I'll learn a huge amount from it. I'm now using the SelectedImageIndex property to store the ID from each row of my database in the tv control. That way I can refer back to the specific record. The only snag is that it does not accept Alpha characters. I was hoping that each node on the TV could be assigned a 'key', for example the 3rd record in the Customer table could be 'Cust3' etc. The only way I can see around this is to add a specific number to each record number, so record 3 from the Customers table would be 100000003 and record 3 from the manufactures table would be 200000003. Do you have any other ideas?

  4. specci48

    specci48 Well-Known Member Licensed User

    Hi blackbox,

    since the selectedImgageIndex was not originally designed to act as a reference to a specific tablerow, I don't have other ideas for you.
    But I think your solution should work well leaving enough space for a lot of tv channels... ;)

  5. x7Q391kt

    x7Q391kt New Member Licensed User

    Thank you so much for posting this. This is very useful!
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice