自定义控件之:treelistCombox 下拉树列表

先来一张效果图

自定义控件之:treelistCombox 下拉树列表_第1张图片

下面是treelistcombox源码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace chuXiangMemberManager.userControls
{
    //[DesignerAttribute(typeof(treeListCombox))]
    public partial class treeListCombox : DevExpress.XtraEditors.PopupContainerEdit
    {
        private DevExpress.XtraEditors.PopupContainerControl popupContainerControl = new DevExpress.XtraEditors.PopupContainerControl();
        private DevExpress.XtraTreeList.TreeList _treeList = new DevExpress.XtraTreeList.TreeList();
        [Browsable(true), Category("Appearance")]
        public DevExpress.XtraTreeList.TreeList TreeList 
        {
            get { return _treeList; }
            set { _treeList = value; }
        }
       
        public treeListCombox()
        {
            _treeList.Name = "TreeList";
            _treeList.OptionsView.ShowColumns = true;
            _treeList.OptionsBehavior.Editable = false;
            popupContainerControl.Height = 200;
            InitializeComponent();
        }
       
        public treeListCombox(IContainer container)
        {
            container.Add(this);
            this.QueryPopUp += new CancelEventHandler(treeListCombox_QueryPopUp);
            popupContainerControl.Width = this.Width;
            this.Properties.PopupControl = popupContainerControl;
            popupContainerControl.Controls.Add(TreeList);
            TreeList.Dock = System.Windows.Forms.DockStyle.Fill;
            popupContainerControl.Height = 200;
            TreeList.OptionsView.ShowColumns = false;
            InitializeComponent();
        }

        void treeListCombox_QueryPopUp(object sender, CancelEventArgs e)
        {
            DevExpress.XtraEditors.PopupContainerEdit popupedit = (DevExpress.XtraEditors.PopupContainerEdit)sender;

            popupContainerControl.Width = popupedit.Width;  
        }
        
    }
}


 

你可能感兴趣的:(控件,c#.net,winform)