private TXTextBox CreateTextBox(string text) { TXTextBox txt = new TXTextBox(); txt.Dock = DockStyle.Fill; txt.Text = text; txt.MaxLength = 12; txt.ReadOnly = !this.EditEnable; return(txt); }
/// <summary> /// 创建并初始化所有控件,包括添加事件处理函数 /// </summary> private void InitControls() { //TextBox this.m_TextBox = new TXTextBox(); this.m_TextBox.ReadOnly = true; this.m_TextBox.KeyDown += new KeyEventHandler(m_TextBox_KeyDown); this.m_TextBox.Parent = this; //Button this.m_DropdownButton = new Button(); Assembly asm = Assembly.GetExecutingAssembly(); System.IO.Stream stream = asm.GetManifestResourceStream(asm.GetName().Name + ".Resources.BM_dropdown.bmp"); Bitmap bm = new Bitmap(stream); this.m_DropdownButton.Image = bm; this.m_DropdownButton.Width = 16; this.m_DropdownButton.Height = this.m_TextBox.Height - 2; this.m_DropdownButton.Location = new Point(this.m_TextBox.Right - 18, 1); this.m_DropdownButton.Click += new EventHandler(m_DropdownButton_Click); this.m_DropdownButton.FlatStyle = FlatStyle.Flat; this.m_DropdownButton.Parent = this; this.m_DropdownButton.BringToFront(); //TreeView this.m_TreeView = new TreeView(); this.m_TreeView.Visible = false; this.m_TreeView.DoubleClick += new EventHandler(m_TreeView_DoubleClick); this.m_TreeView.KeyDown += new KeyEventHandler(m_TreeView_KeyDown); this.m_TreeView.LostFocus += new EventHandler(m_TreeView_LostFocus); this.m_TreeView.BeforeExpand += new TreeViewCancelEventHandler(m_TreeView_BeforeExpand); this.m_TreeView.BeforeCollapse += new TreeViewCancelEventHandler(TreeComboBox_BeforeCollapse); this.m_TreeView.AfterExpand += new TreeViewEventHandler(m_TreeView_AfterExpand); this.m_TreeView.AfterCollapse += new TreeViewEventHandler(TreeComboBox_AfterCollapse); this.m_TreeView.Location = new Point(0, 0); this.m_TreeView.Parent = null; this.LostFocus += new EventHandler(TreeComboBox_LostFocus); }