Binding an enum to a WinForms combo box, and then setting it

前端 未结 28 2163
心在旅途
心在旅途 2020-11-28 04:33

a lot of people have answered the question of how to bind an enum to a combo box in WinForms. Its like this:

comboBox1.DataSource = Enum.GetValues(typeof(MyE         


        
28条回答
  •  星月不相逢
    2020-11-28 05:09

    this is the solution to load item of enum in combobox :

    comboBox1.Items.AddRange( Enum.GetNames(typeof(Border3DStyle)));
    

    And then use the enum item as text :

    toolStripStatusLabel1.BorderStyle = (Border3DStyle)Enum.Parse(typeof(Border3DStyle),comboBox1.Text);
    

提交回复
热议问题