CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009
    Posts
    2

    Nested namespace and dynamic comboboxes

    Hi,

    I am trying to dynamically change the contents of a combobox.
    I want to have the text in the combobox the same as a nested namespace...

    for example.

    namespace Global
    {

    namespace Up
    {
    namespace Left
    {
    }
    namespace Right
    {
    }
    }

    namespace Down
    {
    namespace Left
    {
    }
    namespace Right
    {
    }
    namespace Middle
    {
    }
    }
    }


    And I want to populate a combobox with Left,Right (or Middle)....but I want to populate the combobox depending on the previous namespace (if that makes sense).

    At the moment I was using Enums and hardcoding the options, but now I have added "Middle" and want it to change dynamically.

    Thanks,

    Stephen

  2. #2
    Join Date
    May 2009
    Posts
    2

    Re: Nested namespace and dynamic comboboxes

    Ok,

    I've sorted it now. I was using reflection anyway to load the DLL file. But I've added a bit extra...

    Assembly _assembly = Assembly.LoadFrom(myDLL);
    Types[] _types = _assembly.GetTypes();

    _types holds all the available methods/Enums etc that were in the DLL and can be foreach looped to extract the appropriate ones.




    foreach (Type my_type in _types)
    {
    if (!my_type.IsEnum)
    {
    string name = my_type.Namespace;
    string[] my_name = name.Split('.');
    if (!my_Side.Contains(my_name[1]))
    {
    my_Side.Add(my_name[1]);
    }
    }
    }

    Combo_Side.DataSource = my_Side;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured