Here's a non elegant solution, which probably isn't the best way to do it. If anyone can approve upon it, PLEASE LET ME KNOW:
private string _SelectedObject = "Unknown";
[Category("Custom"), TypeConverter(typeof(SelectedObjectConverter))]
public string SelectedObject
{
get { fillit(); return _SelectedObject; }
set { _SelectedObject = value; }
}
private void fillit()
{
if (this.Parent == null) return;
string[] controlStrings = new string[(this.Parent as Control).Controls.Count];
for (int i = 0; i < (this.Parent as Control).Controls.Count; i++)
{
controlStrings[i] = (this.Parent as Control).Controls[i].Name;
}
SelectedObjectConverter.SelectedObjects = new SelectedObjectConverter.StandardValuesCollection(controlStrings);
}
private class SelectedObjectConverter : StringConverter
{
public static StandardValuesCollection SelectedObjects = new StandardValuesCollection(new string[0]);
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true;
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => false;
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) => SelectedObjects;
}