개체 목록이 있습니다. 내 클래스는 다음과 같습니다C# 일반 목록 필터
class Line
{
public string A { get; set; }
public object B { get; set; }
public string C { get; set; }
}
class More_B
{
public Information Information { get { return _Information; }}
public Description Description { get { return _Description ; }}
private Information _Information = new Information();
private Description _Description = new Description();
}
class Information
{
public string Name { get; set;}
public string Type { get; set;}
public string Further_Info { get; set;}
}
를 내 메인 클래스에서이 같은 Line
클래스 내부의 모든 데이터를 얻을 수 끝에.
More_B info = new More_B();
Line main = new Line();
main.A = "Information about device";
main.B = info;
main.C = "Some more information could be display here";
list3.Add(main);
그래서 말에 나는 어떤 안에 내가 3 개 필드 A
B
C
이 목록을 가져옵니다. A
및 C
에 내 문자열 값이 있고 B
에 디버그 모드를 확인할 때 정보 객체가 있고 그 안에는 Name
Type
및 Further_Info
과 같은 모든 필드가 있습니다.
나중에이 값을 "Name" "Type"및 "Further_Info"값을 기준으로 필터링하려면이 방법을 시도했지만 작동하지 않습니다. (RowFilter를 사용할 수 있도록 DataView에 내 목록을 바인딩했습니다.)
view2.RowFilter = "Line like '%" + textBox2.Text + "%'";
어떻게하면됩니까?
저는 C#에 익숙하지 않습니다. 제발 잘못했으면 용서해주세요. 이해하기 어려운 것이 있으면 알려주세요. 내가 한 일을 설명하는 코드를 더 게시하려고합니다.
편집 : 나는이 문장 view2.RowFilter = "Line like '%" + textBox2.Text + "%'";
를 사용할 때 나는 오류 Cannot perform 'Like' operation on read_display.More_B and System.String.
EDIT2를 얻을 : 내 클래스에 대한 데이터 테이블 작성을위한 2 개 방법이 다음 내가 이런 식으로 작업을 수행합니다 DataTable ListAsDataTable2 = BuildDataTable2<Line>(list3); DataView ListAsDataView2 = ListAsDataTable2.DefaultView; this.dataGridView4.DataSource = view2 = ListAsDataView2;
'view2' 란 무엇입니까? – xanatos
view2는 내 DataView의 개체입니다. RowFilter를 사용하려면이 방법을 사용했습니다. 이 데이터를 DataView에 바인딩하지 않으면 작동하지 않습니다. – user2592968
Binding에 사용하는 우편 번호 –