标签:
private DataSet GetTestData() { DataSet dataSet = new DataSet(); DataTable dataTableSeries = new DataTable("BusinessProcess"); dataTableSeries.Columns.Add("业务过程", typeof(string)); dataTableSeries.Columns.Add("UsedPT", typeof(string)); dataTableSeries.Columns.Add("GeneratePT", typeof(string)); dataTableSeries.Rows.Add(new object[] { "业务过程", "T", "T" }); DataTable dataTableSpinoffs = new DataTable("Spinoffs"); dataTableSpinoffs.Columns.Add("ParentRecord", typeof(string)); dataTableSpinoffs.Columns.Add("业务过程", typeof(string)); dataTableSpinoffs.Columns.Add("UsedPT", typeof(string)); dataTableSpinoffs.Columns.Add("GeneratePT", typeof(string)); dataTableSpinoffs.Rows.Add(new object[] { "业务过程", "规划计划A", "F", "T" }); dataTableSpinoffs.Rows.Add(new object[] { "业务过程", "规划计划B", "F", "F" }); dataTableSpinoffs.Rows.Add(new object[] { "业务过程", "规划计划C", "T", "F" }); dataTableSpinoffs.Rows.Add(new object[] { "规划计划A", "勘探规划a", "F", "F" }); dataTableSpinoffs.Rows.Add(new object[] { "规划计划A", "勘探计划a", "T", "F" }); dataTableSpinoffs.Rows.Add(new object[] { "规划计划B", "勘探规划b", "F", "T" }); dataTableSpinoffs.Rows.Add(new object[] { "规划计划B", "勘探计划b", "F", "F" }); dataTableSpinoffs.Rows.Add(new object[] { "规划计划C", "勘探规划c", "T", "F" }); dataTableSpinoffs.Rows.Add(new object[] { "勘探规划a", "中长期油气勘探规划", "F", "F" }); dataTableSpinoffs.Rows.Add(new object[] { "勘探规划a", "五年期油气勘探滚动规划", "T", "T" }); dataTableSpinoffs.Rows.Add(new object[] { "勘探计划b", "年度勘探计划", "T", "T" }); dataTableSpinoffs.Rows.Add(new object[] { "勘探计划b", "年度勘探部署", "T", "F" }); dataTableSpinoffs.Rows.Add(new object[] { "勘探计划b", "年度部署调整", "F", "T" }); dataSet.Tables.Add(dataTableSeries); dataSet.Tables.Add(dataTableSpinoffs); dataSet.Relations.Add("dataTableSeries", dataTableSeries.Columns["业务过程"], dataTableSpinoffs.Columns["ParentRecord"], false); dataSet.Relations.Add("SpinoffToSpinoff", dataTableSpinoffs.Columns["业务过程"], dataTableSpinoffs.Columns["ParentRecord"], false); return dataSet; }
this.ultraTree1.ViewStyle = ViewStyle.OutlookExpress; this.ultraTree1.DataSource = GetTestData(); this.ultraTree1.DataMember = "BusinessProcess";
//实现列的自适应(好像不怎么起作用) // this.ultraTree1.ColumnSettings.AutoFitColumns = AutoFitColumns.ResizeAllColumns; //设置列宽(这个比较好用) this.ultraTree1.ColumnSettings.ColumnSets[0].Columns[0].LayoutInfo.PreferredLabelSize = new Size(250, 0);
There is no way to auto-size columns except when using the OutlookExpress ViewStyle:
this.ultraTree1.ColumnSettings.AutoFitColumns = AutoFitColumns.ResizeAllColumns;
其他的样式需要手动设置列的size
UltraTree1.ColumnSettings.ColumnSets(X).Columns(Y).Visible = FalseWhere X is the columnset name / index and Y is the column name / index
标签:
原文地址:http://blog.csdn.net/shiyaru1314/article/details/45500325