Help???

Discussion in 'Questions (Windows Mobile)' started by Cableguy, Jun 19, 2007.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi,

    Im in the early stages of a .chm creation app and got stuck on this thing....

    I'm adding "Modal Forms" to be the topic's of the .chm file and reach the point were I can erase an added "Modal Form" but need to rename all remaining forms numerically....
    like this...


    After creating 5 topics, if the user deletes the 2 and 3 toppics then the next adding topic would be named 4 since 4 and 5 had became 2 and 3...

    add topic 1
    add topic 2
    add topic 3
    add topic 4
    add topic 5

    delete topic 2 - automatically rename 3 to 2, 4 to 3 and 5 to 4
    delete topic 3 - automatically reneme 4 to 3

    Add topic 4

    I think this way it's easier to understand what im trying...

    I just can't work out how to make sure the forms number stay sequenciall...
     
  2. specci48

    specci48 Well-Known Member Licensed User

    Hi Cableguy!

    What about an arraylist?

    Add topicA
    Add topicB
    Add topicC
    Add topicD
    Add topicE

    Now you arraylist contains 5 elemtents. The topic number is the result of the array index.
    If the user wants to delete the 2nd and 3rd topic you can use removeItemAt.
    Be sure to begin always with the highest number!

    RemoveAt(3)
    topicA
    topicB
    topicD
    topicE

    RemoveAt(2)
    topicA
    topicD
    topicE

    To Add a topic at the end use AddItem(topicF)
    topicA
    topicD
    topicE
    topicF

    Additionally you can use e.g. Insert(2,TopicG) to put a new topic to a certain place
    topicA
    topicD
    topicG
    topicE
    topicF

    To get the number of a topic name you can use IndexOf, e.g. IndexOf(topicE) = 4


    Does my explanation help?

    specci48
     
  3. Cableguy

    Cableguy Expert Licensed User

    THanks for Your sugestion, but you said to make sure tt start from the highest index number..Since each index is removed one by one, how does this affect the array?
     
  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I think that Specci48 meant if selecting multiple forms for deletion then start from the top, since you intend to delete forms one-by-one then this doesn't apply.

    PS. Nice solution Specci48 :cool:

    Regards,
    RandomCoder.
     
  5. specci48

    specci48 Well-Known Member Licensed User

    I think Cableguy wants to be sure, that removing or adding an item to the arraylist does NOT change the actual order of the items (until you sort them manually with ArrayList.Sort).

    And as far as I know removing/adding an item to an ArrayList has no sideeffect to the actual order.


    specci48
     
Loading...