Hallo,
ich möchte die möglichen Werte ("Sachen") von "MyProperty" gerne in der Eigenschaftenseite ComboBox-artig anzeigen lassen, so dass ich dort zur Entwurfszeit einen angeben kann.
Was muss ich tun? Gibt es spezielle Attribute dafür? Mit einem Enum statt Struct funktioniert es problemlos:
public class MyTextBox : TextBox
{
[Browsable(true)]
[Category("MeineKategorie")]
public StatischeKlasse.Sache MyProperty { get; set; }
}
public static class StatischeKlasse
{
public struct Sache
{
public string Farbe;
public int Gewicht;
}
public struct Sachen
{
public readonly static Sache Sache1 = new Sache() { Farbe = "Grün", Gewicht = 3 };
public readonly static Sache Sache2 = new Sache() { Farbe = "Blau", Gewicht = 5 };
public readonly static Sache Sache3 = new Sache() { Farbe = "Rot", Gewicht = 8 };
}
}
Die Property wird im Eigenschaftenfenster zwar angezeigt, ist aber disabled, also grau und nicht auswählbar. Als Wert angezeigt wird dort nur "MyNamespace.StatischeKlasse+Sache".
Bin für jeden Tipp dankbar. Habe mir schon die Finger wund gegoogelt.
Signaturen kosten nur Platz.
Hallo Tippnichgern,
eine Suchanfrage und sofort treffer
http://bytes.com/topic/c-sharp/answers/238511-combobox-propertygrid
Viele Grüße
Lars