Beispiel #1
0
        //加载数据
        private void LoadData(int start, int length)
        {
            List <DbData> datas = _dbClass.GetTableData(_table.TableName, start, length);
            DataTable     dt    = DbData.ToDataTable(datas);

            if (dgvData.Rows.Count == 0 && dgvData.Columns.Count == 0)
            {
                foreach (DataColumn item in dt.Columns)
                {
                    dgvData.Columns.Add(item.ColumnName, item.Caption);
                }
            }
            this.Invoke(new Action(() =>
            {
                foreach (DataRow item in dt.Rows)
                {
                    DataGridViewRow dgvr = new DataGridViewRow();
                    dgvr.CreateCells(dgvData, item.ItemArray);
                    dgvData.Rows.Add(dgvr);
                }
            }));
        }