如何在 C# Winforms 中创建下拉信息框? [英] How to create drop down information box in C# Winforms?
本文介绍了如何在 C# Winforms 中创建下拉信息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想制作一个按钮,它可以下拉包含用户帮助文档的多行标签或表单.
I want to make a button that can drop down a multi-line label or form which contains help documentation for the user.
我已经搜索过,但找不到任何适用于 C# Winforms 的内容.是否存在任何免费控件,或者我必须自己创建它?非常感谢,理查德
I have searched and I can't find anything that is for C# Winforms. Do any free controls out there exist for this or will I have to create it myself? Many thanks, Richard
推荐答案
使用 ToolStripControlHost 和 ToolStripDropDown 控件可以为您提供:
Using ToolStripControlHost and ToolStripDropDown controls can provide this for you:
private void button1_Click(object sender, EventArgs e) {
var helpInfo = new StringBuilder();
helpInfo.AppendLine("This is line one.");
helpInfo.AppendLine("This is line two.");
var textHelp = new TextBox() { Multiline = true,
ReadOnly = true,
Text = helpInfo.ToString(),
MinimumSize = new Size(100, 100)
};
var toolHost = new ToolStripControlHost(textHelp);
toolHost.Margin = new Padding(0);
var toolDrop = new ToolStripDropDown();
toolDrop.Padding = new Padding(0);
toolDrop.Items.Add(toolHost);
toolDrop.Show(button1, button1.Width, 0);
}
结果:
这篇关于如何在 C# Winforms 中创建下拉信息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文