public class G
{
public static DataSet GetDataSet()
{
DataSet ds = new DataSet();
return ds;
}
public static DataTable GetTable()
{
DataTable dt = new DataTable();
dt.Columns.Add("CustomerTitle");
dt.Columns.Add("OrderID");
dt.Columns.Add("Total", typeof(decimal));
for (int i = 0; i < 100; i++)
{
DataRow rowNew = dt.NewRow();
string CustomerTitle = "";
if (i < 30)
{
CustomerTitle = "客户1";
}
else if (i >= 30 && i < 60)
{
CustomerTitle = "客户2";
}
else if (i >= 60)
{
CustomerTitle = "客户3";
}
rowNew["CustomerTitle"] = CustomerTitle;
rowNew["OrderID"] = DateTime.Now.ToString("yyyyMMddHHmmss") + i.ToString();
rowNew["Total"] = i;
dt.Rows.Add(rowNew);
}
return dt;
}
}
private void FormGroup_Load(object sender, EventArgs e)
{
C1FlexGroup _flexGroup = new C1FlexGroup();
_flexGroup.Dock = DockStyle.Fill;
_flexGroup.Grid.DataSource = G.GetTable();
_flexGroup.Grid.TabIndex = 1;
_flexGroup.Grid.Tree.Style = C1.Win.C1FlexGrid.TreeStyleFlags.Symbols;
this.Controls.Add(_flexGroup);
//注意顺序,下面这段代码不能在this.Controls.Add(datagrid);之前
_flexGroup.Grid.AllowFiltering = true;//允许过滤
_flexGroup.Grid.Tree.Show(0);//折叠所有行,如果想展开,去掉此行代码
}
C1FlexGroup这个类用的就是例子中的
|
|