CSV 파일을 읽고 처리 한 후 모바일 응용 프로그램에 DataGrid
을 표시하려고합니다. 여기에 내가 지금까지 가지고있는 것입니다 :DataGrid에 데이터가 표시되지 않습니다.
private void btOpenFile_Click(object sender, EventArgs e)
{
try
{
// Process all data into an array of Object
// this.records array contains objects of type MyRecord
// Create datatable and define columns
DataTable dt = new DataTable("myDt");
dt.Columns.Add(new DataColumn("String A",typeof(string)));
dt.Columns.Add(new DataColumn("Int 1", typeof(int)));
// Loop through and create rows
foreach(MyRecord record in records) {
DataRow row = dt.NewRow();
row[0] = record.stringA;
row[1] = record.int1;
dt.Rows.Add(row);
}
// Create dataset and assign it to the datasource..
DataSet ds = new DataSet("myDs");
ds.Tables.Add(dt);
dataGrid.DataSource = ds;
dataGrid.Refresh();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message,"Error");
}
}
내 응용 프로그램을 실행할 때 빈 데이터 격자 구성 요소가 있습니다. 누군가 내 실수를 지적 할 수 있습니까? 또는이를 올바르게 수행하는 방법은 무엇입니까?
고마워. 하지만 데이터 세트를 사용하여 보여주는 예제가 있습니다. 그것이 왜 효과가 없었던 모든 추론? –