我在C#
中創建了一個windows custom control
,它繼承自TextBox
。如何在自定義控件中添加動態屬性
在我的控制,我的兩個屬性,即Continent
和Country
所以,我需要給提供選擇洲和國家的用戶。
i。 e,如果用戶需要選擇大陸,我將列出所有七大洲,那時國家名單將是空的,
一旦用戶選擇了大陸,那麼country
列表應該填寫選定大陸的國家。
我知道我可以使用enum
這個
即
public enum Continents {Asia , Africa, Antartica, Australia, Europe, NorthAmerica, SouthAmerica }
和財產
public Continents Continent { get; set; }
,如果我這樣設置,那麼continent property
將提供的dropdown list
(名單大洲從上面的enum
)發送給用戶,用戶可以從中選擇(從屬性窗口)。
現在我的問題是,一旦continen
t被選中,那麼用戶應該能夠從屬性窗口中選擇country
。
請幫我做這件事
那麼問題是什麼? – gideon 2012-03-15 05:18:58
@gideon:我無法設置'Country'屬性,因爲它是動態的。更多的我不知道'國家'的類型 – 2012-03-15 05:22:08