DevExpress control of XtraTreeList

2010-10-25  来源:本站原创  分类:DotNet  人气:231 

DevExpress controls, where recent projects useful to the really powerful features, previously on the arrival of a control vs control comes with a few, regarded as a composite control. XtraTreeList control down today to use notes

1.treeList1 binding data

public void InitDate()
        {
            ds = SqlData.QueryDataSet("select deptid,name,code,rootid from dbo.bm_dept");

            treeList1.OptionsBehavior.PopulateServiceColumns = true;
            //this.treeList1.PopulateColumns();
            this.treeList1.ParentFieldName = "rootid";
            this.treeList1.KeyFieldName = "deptid";

            this.treeList1.DataSource = ds.Tables[0];
        }

Which this.treeList1.ParentFieldName = "rootid";
this.treeList1.KeyFieldName = "deptid"; very important ParentFieldName subordinate KeyFieldName field is set to set the field. If A equals B data ParentFieldName field data KeyFieldName field, that A is B's child nodes, set to 0, that A is the root node

So when you add new data, the choice to pay attention KeyFieldName field to establish affiliation

2. Modification to modify the function of the column with XtraGridControl

private void treeList1_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e)
        {
            try
            {
                string colKey = e.Column.FieldName;
                string sqlStr = "";
                switch (colKey)
                {
                        //select deptid,name,code,rootid from bm_dept
                    case "deptid":
                        sqlStr = string.Format("update bm_dept set {0}='{1}' where deptid='{2}'", colKey, e.Value, treeList1.FocusedNode.GetValue("deptid").ToString());
                        break;
                    case "name":
                        sqlStr = string.Format("update bm_dept set {0}='{1}' where deptid='{2}'", colKey, e.Value, treeList1.FocusedNode.GetValue("deptid").ToString());
                        break;
                    default:
                        break;
                }
                if (!sqlStr.Trim().Equals(""))
                    SqlData.ExecuteSql(sqlStr);
                InitDate();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message.ToString());
            }
        }

3. Delete function Note: treeList1.FocusedNode.GetValue ("deptid"). ToString () Get the column value row

private void sBtnDel_Click(object sender, EventArgs e)
        {
            //if(treeList1.FocusedNode != null)
            //    treeList1.DeleteNode(treeList1.FocusedNode);
            int deid = int.Parse(treeList1.FocusedNode.GetValue("deptid").ToString());
            SqlDataReader dr = SqlData.QueryDataReader("select rootid from bm_dept");
            while (dr.Read())
            {
                int rtid = int.Parse(dr["rootid"].ToString());
                if ( rtid== deid)
                {
                    MessageBox.Show(" You cannot delete the root node  ! Please delete the child nodes. "," prompted  ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            if (treeList1.FocusedNode != null)
            {
                if (MessageBox.Show(" Confirm delete? "," prompted  ", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                {
                    try
                    {
                        int i= SqlData.ExecuteSql("delete from bm_dept where deptid='" + treeList1.FocusedNode.GetValue("deptid").ToString() + "'");
                        if (i > 0)
                        {
                            InitDate();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            else
            { MessageBox.Show(" Select the line "," prompted  "); }

        }

4.TreeList drag and drop nodes

string mubiao tuo :// Global variables  

private void treeList1_DragDrop(object sender, DragEventArgs e)
        {
            DevExpress.XtraTreeList.TreeListHitInfo hi = treeList1.CalcHitInfo(treeList1.PointToClient(new Point(e.X, e.Y)));
            mubiao = hi.Node.GetValue("deptid").ToString();

            if (index == 0)
            {
                //MessageBox.Show(" On the lower level of the current node  ");
                string sql = string.Format("update bm_dept set rootid='{0}' where deptid='{1}'", mubiao, tuo);
                SqlData.ExecuteSql(sql);

            }
            else
            {
                //MessageBox.Show(" The sibling of the current node  ");
                SqlDataReader dr = SqlData.QueryDataReader("select rootid from bm_dept where deptid='" + mubiao + "'");
                dr.Read();
                string roots=dr["rootid"].ToString();
                string sql = string.Format("update bm_dept set rootid='{0}' where deptid='{1}'", roots, tuo);
                SqlData.ExecuteSql(sql);
            }

            mubiao = "";
        }

        private void treeList1_DragEnter(object sender, DragEventArgs e)
        {
            tuo = treeList1.FocusedNode.GetValue("deptid").ToString();
        }

        private void treeList1_CalcNodeDragImageIndex(object sender, DevExpress.XtraTreeList.CalcNodeDragImageIndexEventArgs e)
        {
            index = e.ImageIndex;
        }
相关文章
  • DevExpress control of XtraTreeList 2010-10-25

    DevExpress controls, where recent projects useful to the really powerful features, previously on the arrival of a control vs control comes with a few, regarded as a composite control. XtraTreeList control down today to use notes 1.treeList1 binding d

  • DevExpress之TreeList用法实例总结 2015-03-30

    这篇文章主要介绍了DevExpress之TreeList用法,对于C#初学者有一定的借鉴价值,需要的朋友可以参考下 本文实例总结了DevExpress之TreeList用法,希望对大家学习C#程序设计起到一定的帮助作用.具体实例如下: using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using DevExpress.XtraBars; using D

  • (Transfer) Developer Express controls portfolio GridControl control 2010-02-24

    1 ************************************** Developer Express controls portfolio GridControl control, how to automatically display the serial number of each line? For example, 10 data records, I want to record next to 1.2.3.4. Such figures. However, if

  • BCB6 Installation Notes under the devexpress 2010-09-06

    Recently to develop a software in the past to do with the BCB out of control that comes with always feel like a toy, before I played tms, although the line of the tms evaluation can still be pricey, but I do not know why the downloaded version of the

  • DevExpress实现自定义TreeListNode的Tooltip的方法 2014-07-25

    这篇文章主要介绍了DevExpress实现自定义TreeListNode的Tooltip的方法,需要的朋友可以参考下 本文实例展示了DevExpress实现自定义TreeListNode的Tooltip的方法,具体方法如下所示: 主要功能代码如下: /// <summary> /// 为节点提供Tooltip /// 说明: /// 1.设置tree.ToolTipController属性 /// 2.ToolTipController的GetActiveObjectInfo事件中使用 ///

  • DevExpress实现GridControl同步列头checkbox与列中checkbox状态 2015-03-04

    这篇文章主要介绍了DevExpress实现GridControl同步列头checkbox与列中checkbox状态,需要的朋友可以参考下 本文实例展示了DevExpress实现GridControl同步列头checkbox与列中checkbox状态的方法,有一定的实用价值,具体方法如下: 主要功能代码如下: /// <summary> /// 同步列头checkbox与列中checkbox状态 /// </summary> /// <param name="view

  • DevExpress根据条件设置GridControl RepositoryItem是否可编辑 2015-04-29

    这篇文章主要介绍了DevExpress根据条件设置GridControl RepositoryItem是否可编辑,需要的朋友可以参考下 本文实例展示了DevExpress根据条件设置GridControl RepositoryItem是否可编辑的方法. 一般在C#项目的开发中,并不是每个RepositoryItem都可以编辑,往往是有条件性的,需要譬如当A列等于"AA"的时候,B列才可编辑,实现起来在ShowingEditor事件中最为方便,并且加入toolTip提示显得人性化. 主要

  • Commonly used version control software 2009-02-28

    Commonly used version control software According to view the network information, see the general use version control software as follows: (One of the level of reviews from one of http://www.hansky.com/cn/news/select_scm3.html but there is no introdu

  • Universal Data Access Control System Design 2009-02-28

    Figure II: general data rights management system database design Comparison of two maps, we can see that the main changes between them are: 1, increase system resources, information and operation type information, the system resources for the tree st

  • JS to control the size of upload files 2009-03-06

    JS to control the size of upload files: var fileSize = 160; var fileType = "jpg, gif, bmp, png"; var bool = false; / / 0 on behalf of From the type of wrong, one representative of the type of upload correctly var str = ""; function che

  • Who in the end a matter for the quality control? 2009-03-13

    In software, what is the quality. Following this article are compared in detail, I recommend you address. http://www.javaeye.com/topic/65626 If the article too long, I put the definition of software quality extracted summarize. 1. There is no bug doe

  • Rails: a model with different access to the design of access control 2009-03-15

    And want to discuss a U.S. rails access control design problem. If I have a user's model, by its implementation, deleted, changed, the list of functions. Ordinary circumstances, we will achieve similar Scaffold generated code. Default into a user lis

  • Using JS to control the page calls a different style sheet 2009-03-17

    Studied some time ago to use JS to control page changes automatically when the browser calls the different styles of questions, ideally in the blue today, they also see a similar code, special excerpt down for later use. SetAttribute method used to a

  • Role-Based Access Control System Design 2009-04-07

    Role-Based Access Control System Design (2004-7-23 17:06:00) Source: CCW Authors: Wang Jiuhui Access Control Policy are the majority of the application system must be taken into account. In this paper, role-based access control is a new access contro

  • On the progress of software project control 2009-04-08

    [Abstract] August 2008 to December 2008, I participated in a provincial-level wireless operators online business hall three development projects and served as project manager jobs. Online Business Office was the wireless operator's provincial Interne

  • Acegi + Spring + Hibernate + Struts 2 to build role-based access control system 2009-04-16

    filter-name> acegiFilterChain </ filter-name> <filter-class> org.acegisecurity.util.FilterToBeanProxy </ filter-class> <init-param> <param-name> targetClass </ param-name> <param-value> org.acegisecurity.util.F

  • Javascript operations Daquan select control 2009-04-22

    Javascript control operations Daquan select (add, modify, delete, check, empty, to determine existence, etc.) JavaScript [1] to determine whether there select option Value = "paraValue" of Item [2] to select the option to add a Item [3] from the

  • js call ocx control (read and write IC card) 2009-05-02

    1, Register OCX Start ---> cmd ---> regsvr32 *. ocx 2, jsp call ocx <OBJECT height=0 width=0 CLASSID="CLSID:64605B9A-BF10-4F16-9303-5A512469E4DF" CODEBASE="dcic32.cab#version=1,0,0,1">// If you cannot find the control, to t

  • JavaScript to control the page printing and Print Settings 2009-05-04

    Control of the page print normally have two options, a set is to use free of charge ie default print, and the other is developed using a third-party print components, following the introduction is to use the default print ie implementation through Ja

  • Project tracking and control (Project Monitoring and Control) SG Introduction 2009-05-10

    Plan instead of using point of view, and are used to implement. PP plan on how to do, PMC is about how to track the implementation of the plan and at the actual circumstances deviate from the plan to take corrective action. Us first take a look at SG