简体   繁体   English

如何获取动态消息框C#

[英]How to get the dynamic message box c#

I have a windows application where I have created a custom form with text, name , caption and error icon. 我有一个Windows应用程序,在其中创建了带有文本,名称,标题和错误图标的自定义表单。 But what happens is that if the number of characters exceed, then the text doesn't fit the message box and the button position changes automatically and takes the other position and looks unaligned. 但是,发生的情况是,如果字符数超过限制,则文本将不适合消息框,并且按钮位置会自动更改,并占据其他位置,并且看起来不对齐。 I tried all the form properties like Dock,Anchor style, AutoSize but nothing helped. 我尝试了所有表单属性,例如Dock,Anchor样式,AutoSize,但没有任何帮助。 How can I do this? 我怎样才能做到这一点?

Check if wrapping the text ( in the label ) will meet the purpouse. 检查是否将文字换行(在标签中)符合要求。 Following is the link how to wrap the text inside the label. 以下是如何将文本包装在标签内的链接。 please Check the completed thread on this link. 请检查此链接上已完成的主题。 Hope this helps .. 希望这可以帮助 ..

Word wrap for a label in Windows Forms Windows窗体中标签的自动换行

If you are finding a dynamically sized MessageBox , check this: 如果要找到动态大小的MessageBox ,请检查以下内容:

First, I assume your MessageBox is dynamically created. 首先,我假设您的MessageBox是动态创建的。

I suggest you do the following to auto-size your MessageBox: 我建议您执行以下操作以自动调整MessageBox的大小:

// in the constructor of you dialog box
public YourDialog()

{
    InitializeComponent();

    // here contentLabel contains the content you gonna display, and SHOULD be
    // set before this dialog is constructed
    Width = Math.Max(contentLabel.Width + 2*contentLabel.Location.X, ClientSize.Width);
}

If you are looking for a label that allows you to do auto wrapping , check this post as suggested by @kishoreVM: Word wrap for a label in Windows Forms 如果您正在寻找允许您进行自动换行的标签,请按照@kishoreVM的建议检查此信息: Windows窗体中的 自动换行 标签

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

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