DataSet myDataSet = new DataSet();
base_ldglBll ldbll = new base_ldglBll();
System.Collections.ArrayList svCollection = new System.Collections.ArrayList(10);
DataTable artists;
DataTable cds;
private void CreateDataSet()
{
myDataSet = new DataSet();
DataTable ddt = new DataTable();
DataTable dt1 = new DataTable();
ddt=ldbll.GetList1("1=1").Tables[0];
dt1 = ldbll.GetList("1=1").Tables[0];
myDataSet.EnforceConstraints = false;
artists = myDataSet.Tables.Add("artists");
cds = myDataSet.Tables.Add("cds");
DataRow[] rows = ddt.Select();
DataRow[] rows1 = dt1.Select();
artists.Columns.AddRange(new DataColumn[] { new DataColumn("楼栋", typeof(string)) });
cds.Columns.AddRange(new DataColumn[] { new DataColumn("no", typeof(int)), new DataColumn("楼栋", typeof(string)),new DataColumn("楼层",typeof(string)) });
foreach (DataRow row in rows)
{
artists.Rows.Add(row.ItemArray);
}
foreach (DataRow row in rows1)
{
cds.Rows.Add(row.ItemArray);
}
myDataSet.Relations.Add("cds", artists.Columns["楼栋"], cds.Columns["楼栋"]);
DefaultSheetDataModel model = (DefaultSheetDataModel)DataGrid1.ActiveSheet.Models.Data;
foreach (DataTable dt in myDataSet.Tables)
{
dt.DefaultView.AllowNew = false;
}
model.DataMember = "artists";
model.DataSource = myDataSet;
DataGrid1.DataSource = myDataSet;
DataGrid1.ActiveSheet.GetDataView(false).AllowNew = false;
}
private void DataGrid1_ChildViewCreated(object sender, FarPoint.Win.Spread.ChildViewCreatedEventArgs e)
{
e.SheetView.ColumnHeader.DefaultStyle.Renderer = new FarPoint.Win.Spread.CellType.ColumnHeaderRenderer();
e.SheetView.RowHeader.DefaultStyle.Renderer = new FarPoint.Win.Spread.CellType.RowHeaderRenderer();
e.SheetView.SheetCorner.DefaultStyle.Renderer = new FarPoint.Win.Spread.CellType.CornerRenderer();
DataGrid1.InterfaceRenderer = null;
DataGrid1.HorizontalScrollBar.Renderer = null;
DataGrid1.VerticalScrollBar.Renderer = null;
System.Drawing.Font fpFont = new System.Drawing.Font("Arial", 12);
e.SheetView.Cells[0, 0, e.SheetView.RowCount - 1, e.SheetView.ColumnCount - 1].Font = fpFont;
e.SheetView.Cells[0, 0, e.SheetView.RowCount - 1, e.SheetView.ColumnCount - 1].ForeColor = Color.Gray;
e.SheetView.ColumnHeader.Cells[0, 0, 0, e.SheetView.ColumnCount - 1].Font = fpFont;
e.SheetView.ColumnHeader.Cells[0, 0, 0, e.SheetView.ColumnCount - 1].BackColor = DataGrid1.ActiveSheet.ColumnHeader.Cells[0, 0].BackColor;
e.SheetView.ColumnHeader.Cells[0, 0, 0, e.SheetView.ColumnCount - 1].ForeColor = DataGrid1.ActiveSheet.ColumnHeader.Cells[0, 0].ForeColor;
e.SheetView.RowHeader.AutoText = FarPoint.Win.Spread.HeaderAutoText.Blank;
e.SheetView.RowHeader.Cells[0, 0, e.SheetView.RowCount - 1, 0].BackColor = DataGrid1.ActiveSheet.RowHeader.Cells[0, 0].BackColor;
e.SheetView.RowHeader.Cells[0, 0, e.SheetView.RowCount - 1, 0].ForeColor = DataGrid1.ActiveSheet.RowHeader.Cells[0, 0].ForeColor;
e.SheetView.SheetCornerStyle.BackColor = DataGrid1.ActiveSheet.SheetCornerStyle.BackColor;
e.SheetView.AlternatingRows[0].BackColor = DataGrid1.ActiveSheet.AlternatingRows[0].BackColor;
e.SheetView.AlternatingRows[1].BackColor = DataGrid1.ActiveSheet.AlternatingRows[1].BackColor;
e.SheetView.GrayAreaBackColor = Color.Transparent;
svCollection.Add(e.SheetView);
}
|
-
获取选中的子表数据
|