Click to See Complete Forum and Search --> : Nested namespace and dynamic comboboxes


steaky1212
May 5th, 2009, 06:10 AM
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

steaky1212
May 5th, 2009, 08:01 AM
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;