Dev XtraTreeList 學習筆記

來源:互聯網
上載者:User
一、設定載請保留地址http://www.cnblogs.com/vincentluo

     使用dev的樹控制項(XtaTreeList)來顯示有父子關係的分類,

資料庫表中只要三列:ParentID,CategoryID,CategoryName;

將控制項的屬性ParentFieldName設定為ParentID,屬性KeyFieldName設定為CategoryID;

先,如所示:

          點擊Run Designer,先添加兩列,設定他們的FieldName,這樣用來綁定資料;分類編號的Visible=false可以進行隱藏;

如:

 

二、綁定 載請保留地址http://www.cnblogs.com/vincentluo

      資料繫結很簡單了

返回DataTable就可以了:

   private void BindCategories()
{
DataTable dt = Info.Get_Categories();
tlCategoryList.DataSource = dt;
}
三、操作載請保留地址http://www.cnblogs.com/vincentluo

      按一下滑鼠節點時,擷取節點資訊

private string CategoryID = null;
private string CategoryName = null;
private void tlCategoryList_MouseDown(object sender, MouseEventArgs e)
{
#region 擷取點擊節點的資訊
TreeListHitInfo hi = tlCategoryList.CalcHitInfo(e.Location);
TreeListNode CurrentNode = hi.Node;
if (CurrentNode != null)
{
CategoryID = CurrentNode.GetValue("CategoryID").ToString();
CategoryName = CurrentNode.GetValue("CategoryName").ToString();
}
#endregion
if (e.Button == MouseButtons.Left)//左鍵
{
//Do something
lblCategoryName.Text = CategoryName;
}
else if (e.Button == MouseButtons.Right)//右鍵
{
//Do something
}
}

另:右鍵的快顯功能表使用了ContextMenuStrip,添加相關節點,綁定到XtaTreeList即可:設定XtaTreeList的ContextMenuStrip

菜單的單擊事件:

 private void treeShowMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
ShowDialogForm sdf = new ShowDialogForm("提示","正在載入,請稍候......");
ToolStripItem item = e.ClickedItem;

if (item.Name == "MenuAddCategory")
{
CategoryEditFrm.GetInstance(-1,0);
}
if (item.Name == "MenuAddChildCategory")
{
CategoryEditFrm.GetInstance(int.Parse(CategoryID), 1);
}
if (item.Name == "MenuEditCategory")
{
CategoryEditFrm.GetInstance(int.Parse(CategoryID),2);
}
else if (item.Name == "MenuEditLink")
{
LinkEditFrm.GetInstance();
}

然後進入編輯頁面,如:

儲存提示:(提示效果見:Dev 等待提示 WaitDialogForm 另外版)

 

四、最後 轉載請保留地址http://www.cnblogs.com/vincentluo

    dev 的XtraTreeList很強大,可以選擇節點然後直接進行拖動,本篇暫時寫這麼多,如果有更新的會另開隨筆記錄下來,更多功能待發覺;

大家有更好的建議,請多多指導

轉載請保留地址http://www.cnblogs.com/vincentluo


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.