c#devexpres TreeList 最簡單顯示動態值的應用


   為了讓數據顯示在行內,也為熟練一下devexpress treelist  控件, 查找了很多,最多的是先把數據放在datatable  表里邊, 然后賦值給treelist的datasource 的方式

因為我的數據就是一列或者兩列沒有子節點.所以這種方式感覺有些麻煩

最終用append 方式賦值.

public static void ShowOnTreeList(TreeList control, string mess)
{
if (control.InvokeRequired)
{
control.BeginInvoke(new MethodInvoker(delegate
{
control.AppendNode(new object[] { mess }, null);
// control.Items.Add(mess);
//control.AppendText(mess + "\r\n");
}));
}
else
{
control.AppendNode(new object[] { mess }, null);
}
}

 

順便把顯示行號的方法放在這

private void tlhand_CustomDrawNodeIndicator(object sender, DevExpress.XtraTreeList.CustomDrawNodeIndicatorEventArgs e)
{
TreeList tree = sender as DevExpress.XtraTreeList.TreeList;
tree.IndicatorWidth = 30;
IndicatorObjectInfoArgs args = e.ObjectArgs as IndicatorObjectInfoArgs;
args.DisplayText = (tree.GetVisibleIndexByNode(e.Node) + 1).ToString();
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM