내 목표는 DataGrid
내 구조에 대한 정보를 "발견"할 수 있도록하는 DataTable
유사한 내 사용자 정의 구조에 결합하는 것이었다.
This Question이 처리에 많은 도움이 CustomTypeDescriptor
에서 상속 (또는 ICustomTypeDescriptor
를 구현)뿐만 아니라
IList
IEnumerable
ITypedList
:
짧은 대답은 다음과 같은 인터페이스를 구현하는 것입니다 CustomTypeDescriptor
가장 힘들었던 물건.
내 열거 형 개체는 기본 테이블에 다시 참조를 저장 한 개체로, 특정 행과 열의 값이 무엇인지 물어볼 수 있습니다.
public AgilityTableRow(AgilityTableBase table, int rowIndex)
{
_table = table;
_rowIndex = rowIndex;
}
public object this[int columnIndex]
{
get
{
return _table[columnIndex, _rowIndex];
}
}
public object this[string columnName]
{
get
{
return _table[_table.GetFieldIndex(columnName), _rowIndex];
}
}
참고 :이 클래스는 ICustomTypeDescriptor
를 구현해야하고 단순히 속성을 얻기 위해 테이블에 전화를 전달할 수 있습니다 :
public PropertyDescriptorCollection GetProperties()
{
return _table.GetProperties();
}
을