简体   繁体   English

如何使用下拉菜单创建用户控件组合框

[英]How to create user control combobox with dropdown

I am learning about creating user controls, although I've been programming c# for many years. 尽管我已经从事c#编程多年,但我正在学习创建用户控件的知识。 What I am trying to achieve is a multi-column combobox with auto-complete that 1: allows more than 1 character when searching and 2: displays all columns when auto-completing. 我要实现的是一个具有自动完成功能的多列组合框:1:在搜索时允许多个字符,2:在自动填充时显示所有列。 I have found nothing like it out there. 我什么都没找到。

I am intending to implement it using a TextBox, a button for opening the dropdown, and a panel control that contains a lightweight datagrid. 我打算使用一个TextBox,一个用于打开下拉菜单的按钮以及一个包含轻量级数据网格的面板控件来实现它。

I can get the TextBox & Button to display fine, and the button event fires as well. 我可以使TextBox和Button正常显示,并且也触发按钮事件。 What I cannot figure out is how to create & display the panel control. 我不知道是如何创建和显示面板控件的。 I've tried adding the panel to the user control using this.Controls.Add(panel) and also tried adding it to the parent form. 我尝试使用this.Controls.Add(panel)将面板添加到用户控件中,还尝试将其添加到父窗体中。

Sorry if this is a simple question or I'm missing something obvious. 抱歉,如果这是一个简单的问题,或者我缺少明显的内容。 I have gone through the MS walkthrough and another tutorial but they don't demonstrate how to make a dropdown panel appear dynamically. 我已经完成了MS演练和另一个教程,但它们没有演示如何使下拉面板动态显示。

THANKS in advance for any advice or pointers! 预先感谢您的任何建议或指示!

除了使用常规按钮之外,还可以使用ToggleButton,然后在切换按钮时使用其状态显示弹出窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM