//设置树List
private void setTreeList() {
DataTable dt = new DataTable();
StringBuilder sbSql = new StringBuilder();
sbSql.Length = 0;
//固定数据源
sbSql.Append("Select CAT_ID,CAT_NAME,P_ID From MAPS_MST_CATEGORY Where 1=1 ");
try
{
dt = DataAccess.Query(sbSql.ToString());
treeList1.Columns.Clear();
treeList1.DataSource = dt;
treeList1.KeyFieldName = "CAT_ID";
treeList1.ParentFieldName = "P_ID";
//默认全展开
//treeList1.ExpandAll();
//把焦点设置在第一个NODE,这样防止树形结构会展开
treeList1.FocusedNode = treeList1.Nodes[0];
//设置各级有线条连接
treeList1.LookAndFeel.UseDefaultLookAndFeel = false;
treeList1.LookAndFeel.UseWindowsXPTheme = true;
//设置为不可编辑
treeList1.OptionsBehavior.Editable = false;
treeList1.OptionsView.ShowColumns = false;
}
catch (Exception ex)
{
throw ex;
}
}