データセットからデータグリッドをより速く埋める方法について質問したいと思います。私は大量のデータ(約8000行)を扱っています。私はC#を使用しています。ネット。私はコードの2つのバージョン(下)を持って、両方のデータの読み込みを完了するために約1分かかった。データセットからDataGridを書き込む
// First Code
DataSet objDataSet = new DataSet();
objDataSet = objMemberShip.mtdMemberViewBy(strGlobalUserID, 0, "", ref intErrNo);
datagrid1.DataSource = objDataSet.Tables[0];
// Second Code
objDataSet = objMemberShip.mtdMemberViewBy(strGlobalUserID, 0, "", ref intErrNo);
datagrid1.Rows.Clear();
for (int intCount = 0; intCount <= objDataSet.Tables[0].Rows.Count - 1; intCount++)
{
string[] strRow = new string[] { objDataSet.Tables[0].Rows[intCount] ["trTranId"].ToString(), objDataSet.Tables[0].Rows[intCount]["strCEMCode"].ToString(),
objDataSet.Tables[0].Rows[intCount]["strName"].ToString(), objDataSet.Tables[0].Rows[intCount]["strAddress"].ToString(),
objDataSet.Tables[0].Rows[intCount]["strTestCenterId"].ToString(), objDataSet.Tables[0].Rows[intCount]["TCr_Name"].ToString(),
objDataSet.Tables[0].Rows[intCount]["strMemberId"].ToString(), objDataSet.Tables[0].Rows[intCount]["TCr_GL_Code"].ToString()};
datagrid1.Rows.Add(strRow);
}
WinFormsまたはWPFを使用していますか?グリッドビューでグループ化が有効になっていますか? – Fischermaen
私はWinFormsを使用しています – marai
両方とも同じ時間がかかる場合、最初のものと一緒に行く。私は別の選択肢があるとは思わない。 – Icarus