이미 데이터가 있다고 가정 할 수있는 DataView로 DataGridView를 채우고 싶습니다. 나는 이것을 수행하는 방법을 찾고 있었지만 모든 솔루션은 DataView 이외의 다른 데이터 구조를 포함하거나이 프로젝트에서 구현할 수없는 다른 라이브러리를 사용합니다. 처음에 DataView를 다른 것으로 변환해야하고 DataGridView를 채우는 데 사용해야합니까? 아니면 비슷한 방식으로 정보를 표시하는 DataGridView보다 사용할 수있는 뭔가가 있습니까?DataView로 DataGridView 채우기
1
A
답변
1
DataGridView
의 DataSource
속성을 DataView
으로 설정해보십시오. DataSource
은 모두 DataView
에 의해 구현되는 IBindingListView
또는 IList
인터페이스 (이 경우에는 다른 옵션과 함께)를 구현할 수 있습니다. 은 MSDN 확인 자세한 내용은
:
1
How to: Bind a DataView Object to a Windows Forms DataGridView Control
이것은 내가 잘못 읽기이 문서가 문제를 해결하지만, 만약 그렇다면 코멘트 나는 시도하고 도움이되지 않습니다 어쩌면 모든 기본, 난 그냥 봤 "DataView를하는 datagridview.datasource"입니다
private void GetData()
{
try
{
// Initialize the DataSet.
dataSet = new DataSet();
dataSet.Locale = CultureInfo.InvariantCulture;
// Create the connection string for the AdventureWorks sample database.
string connectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;"
+ "Integrated Security=true;";
// Create the command strings for querying the Contact table.
string contactSelectCommand = "SELECT ContactID, Title, FirstName, LastName, EmailAddress, Phone FROM Person.Contact";
// Create the contacts data adapter.
contactsDataAdapter = new SqlDataAdapter(
contactSelectCommand,
connectionString);
// Create a command builder to generate SQL update, insert, and
// delete commands based on the contacts select command. These are used to
// update the database.
SqlCommandBuilder contactsCommandBuilder = new SqlCommandBuilder(contactsDataAdapter);
// Fill the data set with the contact information.
contactsDataAdapter.Fill(dataSet, "Contact");
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
}
관련 문제
- 1. DataGridView Winforms ComboBoxCell 채우기
- 2. DataView로 필터링
- 3. 저장 프로 시저에서 DataGridView 채우기
- 4. System.Linq.IorderedEnumerable을 DataView로 변환
- 5. VB.NET : 저장 프로 시저에서 DataGridView 채우기
- 6. subsonic & vb.net으로 datagridview 콤보 상자 채우기
- 7. MVP를 사용하는 Combobox 및 DataGridView 채우기
- 8. vb.net 2010 datagridview 문제 - 데이터가 첫 번째 행을 채우기 만합니다.
- 9. DataGridView 내 하위 DataGridView
- 10. "채우기"채우기
- 11. 스레드를 사용하여 Gridview에 데이터 채우기
- 12. 조건부로 채우기 색 채우기
- 13. 전체 GridLines 표시 .NET DataGridView
- 14. DataGridView comboboxcolumn 동적 바인딩
- 15. DataGridView 문제
- 16. 상단의 DataGridview
- 17. DataGridView ICustomTypeDescriptor
- 18. DataGridView Scaling
- 19. custom datagridview
- 20. DataGridView 페이징
- 21. DataGridView 대신
- 22. scroll DataGridView
- 23. DataGridView 스크롤
- 24. DataGridView 바인딩
- 25. DataGridview 선택
- 26. DataGridView C#
- 27. DataGridView HasErrors?
- 28. DataGridView ComboBox
- 29. DataGridView 비우기
- 30. DataGridView 정렬
은 분명히 난 그냥 DataView의 Table 속성을 사용할 수 있습니다와 같은 것을 사용 DataGridView의 DataSource입니다. 나는 그것을 시도해보고 그것이 효과가 있다면 해결책으로 두겠다. – Boumbles