[英]MessageBox Text from Settings
I would like to set my WinForm
controls' text from the Settings. 我想从设置中设置我的
WinForm
控件的文本。
In case I would like to change in the future the program language, it is quite easy; 如果我想在将来改变程序语言,这很容易;
Just have to modify the appropriate settings. 只需要修改适当的设置。
One of the messageBoxes
text has a line break ( \\n
). 其中一个
messageBoxes
文本有一个换行符( \\n
)。
When I insert its text from Settings, the \\n appears as part of the text and there is no line- break. 当我从“设置”中插入文本时,\\ n将显示为文本的一部分,并且没有换行符。
MessageBox.Show(P_Settings.NotificationMessageBoxes.Default.ProcessFinishedNotification,
P_Settings.NotificationMessageBoxes.Default.ProcessFinishedNotificationTitle,
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
Any ideas? 有任何想法吗?
This should work for you 这应该适合你
string somestring = @"this is some text \n Some more text";
somestring = somestring.Replace(@"\n", Environment.NewLine);
MessageBox.Show(somestring);
Replace: 更换:
MessageBox.Show(P_Settings.NotificationMessageBoxes.Default.ProcessFinishedNotification,
P_Settings.NotificationMessageBoxes.Default.ProcessFinishedNotificationTitle,
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
With: 附:
MessageBox.Show(P_Settings.NotificationMessageBoxes.Default.ProcessFinishedNotification.Replace(@"\n", Environment.NewLine)),
P_Settings.NotificationMessageBoxes.Default.ProcessFinishedNotificationTitle,
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
Replace will check for \\n
and replaces it with: Environment.NewLine
. 替换将检查
\\n
并将其替换为: Environment.NewLine
。 The Escape sequences
have no meaning within actual string objects. Escape sequences
在实际的字符串对象中没有意义。 Only when the C# compiler interprets them. 只有当C#编译器解释它们时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.