C#中怎么在ComboBox的下拉列表中加入树形控件?

来源:百度知道 编辑:UC知道 时间:2024/05/22 15:50:40

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace UserControls
{
/// <summary>
/// TreeViewComboBox 的摘要说明。
/// </summary>
public class TreeViewComboBox : UserControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private Container components = null;

public delegate void EventHandle(TreeNode n);
public event EventHandle AfterSelectedNode;

private bool _allowSelectParentNode = false;

public TreeViewComboBox()
{
this.InitializeComponent();

// Initializing Controls
this.pnlBack = new Panel();
this.pnlBack.BorderStyle = BorderStyle.Fixed3D;
this.pnlBack.BackColor = Color.White;
this.pnlBack.AutoScroll = false;

this.tbSelectedValue = new TextBox();
this.tbSelectedValue.BorderStyle = BorderStyle.No