combobox.Datasource = DataTable;
로 해서 클래스가 로드될 때 바로 selectedIndex를 주려고 하니 에러가 났다.
combobox.items.count 를 찍어보니 0이 자꾸나옴.
그래서 저 문장 아래에 combobox.BindingContext = new BindingContext()
해주니까 정상적으로 작동...
After binding a list to combobox, its dataSource.Count is 5 but, combobox item count is 0. how can it be? I'm used to Web programming and this
is in Windows Forms. So no The problem here is, I'm trying to set the selected item programmatically. Since I don't see the combo.Items collection filled, I cannot set the desired item. Update A total update is needed I guess:
So the problem is here; since after databound no items are there in the ItemCollection of combobox; I cannot search for one to match and set the appropriate one. Here is a image for better understanding (But I'm pretty sure I'm missing sth simple) | |||
show 5 more comments |
After adding
| |||||
|
'C#' 카테고리의 다른 글
c# 이미지 db에 저장 (0) | 2014.07.02 |
---|---|
c# filestream 형식 또는 네임스페이스 이름을 찾을 수 없습니다. (0) | 2014.07.02 |
읽기 전용 필드에 바인딩된 datagridview (0) | 2014.06.29 |
c# datagridview change current selected row (0) | 2014.06.28 |
c# numericupdown valuechanged 문제 (0) | 2014.06.28 |
DataTextField
andDataValueField
accordingly? – Andre Calil Aug 6 '12 at 14:22DisplayMember
andValueMember
. What datatype is in DataSource? – Mr47 Aug 6 '12 at 14:29