TreeViewPersons.Add C# (CSharp) Method

Add() public method

public Add ( string jumperID, string jumperName ) : void
jumperID string
jumperName string
return void
    public void Add(string jumperID, string jumperName)
    {
        TreeIter iter = new TreeIter();
        bool iterOk = store.GetIterFirst(out iter);
        int found = -1;

        int count = 0;
        if(iterOk) {
            do {
                //search until find when jumperName is lexicographically > than current row
                if(String.Compare(jumperName.ToUpper(),
                            ((string) treeview.Model.GetValue (iter, 1)).ToUpper()) < 0 ) {
                    found = count;
                    break;
                }
                count ++;
            } while (store.IterNext (ref iter));
        }

        TreeIter iter2 = new TreeIter();

        if(found != -1) {
            //store.Insert (out iter2, found);
            iter2 = store.InsertNode (found);
            //first ID, then Name
            store.SetValue (iter2, 0, jumperID);
            store.SetValue (iter2, 1, jumperName);
            store.SetValue (iter2, 2, ""); //restTime
        } else {
            //first ID, then Name
            iter2 = store.AppendValues (jumperID, jumperName, "");
        }

        //scroll treeview if needed
        TreePath path = store.GetPath (iter2);
        treeview.ScrollToCell (path, null, true, 0, 0);
    }