[DevExpress] Get the set of nodes in the visible region of TreeList, devexpresstreelist

Source: Internet
Author: User

[DevExpress] Get the set of nodes in the visible region of TreeList, devexpresstreelist

Key code:

/// <Summary> /// obtain the nodes in the visible area /// </summary> /// <param name = "treeList"> TreeList </param> /// <param name = "conditonHanlder"> condition DeleGate </param> // <returns> visible region node set </returns> public static List <TreeListNode> GetVisibleNodes (this TreeList treeList, predicate <TreeListNode> conditonHanlder) {List <TreeListNode> _ visibleNodes = new List <TreeListNode> (); RowsInfo _ rowsInfo = treeList. viewInfo. rowsInfo; foreach (RowInfo ri in _ rowsInfo. rows) {TreeListNode _ curNode = ri. node; if (conditonHanlder (_ curNode) {_ visibleNodes. add (_ curNode) ;}} return _ visibleNodes ;} /// <summary> /// obtain the nodes in the visible area /// </summary> /// <param name = "treeList"> TreeList </param> /// <returns> visible region node set </returns> public static List <TreeListNode> GetVisibleNodes (this TreeList treeList) {return GetVisibleNodes (treeList, n => 1 = 1 );}

Code usage:

MessageBox.Show(tvwLamp.LHTree.GetVisibleNodes(n => n.GetNodeType() == NodeType.Cab).Count.ToString());

Hope this is helpful!


How to bind DevExpress in C # To XtraTreeList Parent and Child Nodes

This. treeList. DataSource = dt;

This. treeList. ParentFieldName = "Father_City_Id ";

This. treeList. KeyFieldName = "CityId ";

This is almost the case.

Q: How does the DEVExpress TreeList control bind data? Which event triggers binding? Now

Bind
Private void initTree ()
{

String sqltree = "select fitemid id, fnumber code, fname name, fparentid parentid from T_ITEM where fitemclassid = 4 and fdeleted = 0 and substring (fnumber, 1, 1) = '8' and fdetail = 0 ";
DataTable dtTree = SqlFunc. ExecSQL (sqltree );
TreeList1.DataSource = dtTree;
TreeList1.Columns ["id"]. Visible = false;
TreeList1.Columns ["parentid"]. Visible = false;
TreeList1.ExpandAll ();
GridView1.OptionsView. AllowCellMerge = true;
}
Click Event
Private void treelistpolicfocusednodechanged (object sender, DevExpress. XtraTreeList. FocusedNodeChangedEventArgs e)
{
DataRowView drv = (DataRowView) treeList1.GetDataRecordByNode (treeList1.FocusedNode );
DataRow dr = drv. Row;
Int p = Convert. ToInt32 (dr [0]);
..................
}
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.