반응형
c#기본 combo box
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | //아이템 추가 1 cboPriorty.DisplayMember = "Value" ; cboPriorty.ValueMember = "Key" ; cboPriorty.Items.Add( new { Value = "high" , Key = "high" }); cboPriorty.Items.Add( new { Value = "normal" , Key = "normal" }); string value = (cboPriorty.SelectedItem as dynamic).Value; //아이템 추가 2 cboTest.DisplayMember = "Value" ; cboTest.ValueMember = "Key" ; Dictionary< string , string >dic = new Dictionary< string , string >(); dic.Add( "1" , "11111" ); dic.Add( "2" , "22222" ); dic.Add( "3" , "33333" ); cboTest.DataSource = items; //cboTest.DataSource = new BindingSource(dic, null); string value = ((KeyValuePair< string , string = "" >)cboTest.SelectedItem).Value; //아이템 추가 3 cboTest.DisplayMember = "Text" ; cboTest.ValueMember = "Value" ; var items = new [] { new { Text = "report A" , Value = "reportA" }, new { Text = "report B" , Value = "reportB" }, new { Text = "report C" , Value = "reportC" }, new { Text = "report D" , Value = "reportD" }, new { Text = "report E" , Value = "reportE" } }; cboTest.DataSource = items; </ string ,> |
반응형
'Winform' 카테고리의 다른 글
.net socket chatting sample (2) SocketCommon (0) | 2021.04.15 |
---|---|
.net socket chatting sample (1) (0) | 2021.04.15 |
Devexpress Grid CustomSummaryCalculate(그리드 특정 조건만 sum) (0) | 2019.05.21 |
[DevExpress] 그리드의 체크박스 한개만 선택 할때 (0) | 2019.01.23 |
[DevExpress] TextEdit에 Invalid Value 아이콘 제거 하기. (4) | 2019.01.22 |
댓글