如何在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的任何东西。是否为此存在任何免费控件,还是我必须自己创建它?
非常感谢,
Richard
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屋!
查看全文