views:

385

answers:

1

Hello out there,

im trying to build my first application on Windows forms with C#. Im fighting against the treeview control and MS outlook 2007...

I need a treeview like the Explorer in Outlook 2007, the exchange public folders preselected.

I have created the parent node, but i have problems to get all child nodes.

Now, Im getting only teh first level

Can anyone help? Thanks a lot for wasting your time for my "problem" :)

I started with this code:

private void TreeViewOutlookPublicFolders_Click(object sender, EventArgs e)
    {
        // Initalisieren der Oulook Session
        Microsoft.Office.Interop.Outlook.Application OlApp = new Microsoft.Office.Interop.Outlook.Application();
        Microsoft.Office.Interop.Outlook.NameSpace OlNs = OlApp.GetNamespace("MAPI");
        Microsoft.Office.Interop.Outlook.MAPIFolder StartFolder = OlNs.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);


        // Display a wait cursor while the TreeNodes are being created.
        Cursor.Current = Cursors.WaitCursor;

        // Suppress repainting the TreeView until all the objects have been created.
        TreeViewOutlookPublicFolders.BeginUpdate();

        // Clear the TreeView each time the method is called.
        TreeViewOutlookPublicFolders.Nodes.Clear();

        TreeNode TRoot = TreeViewOutlookPublicFolders.Nodes.Add(StartFolder.Name);

        foreach ( Folder f in StartFolder.Folders)

        {
            Debug.Print(f.Name);
            TRoot.Nodes.Add(f.Name);
        }

        // Reset the cursor to the default for all controls.
        Cursor.Current = Cursors.Default;

        // Begin repainting the TreeView.
        TreeViewOutlookPublicFolders.EndUpdate();

    }
A: 

Updated answer: Here's a tutorial that may explain what it is you're trying to do. Take a look and see if this helps you.

/matt

Can you elaborate a bit on what you're "fighting against" with the treeview? You've created the parent and child nodes I'm assuming, but is your problem that you're unable to open the form with a folder preselected or something else?

/matt

Matt Dewey
I have created the parent node, but i have problem to get the child nodes.. the problem is teh beginning, i guess