errorProvider.SetError(control, message)
来显示消息,但是仅显示Icon
,但未显示该消息,这是怎么回事?是否可以仅调整错误消息的左边距? (我知道您可以SetIconPadding
,但我只希望更改左边距)
public static DialogResult ShowDialog()
{
var inputBox = new Form { ClientSize = new Size(520, 225), FormBorderStyle = FormBorderStyle.FixedDialog };
var panel = new TableLayoutPanel { Size = new Size(460, 100), Location = new System.Drawing.Point(45, 15) };
var errorProvider = new ErrorProvider { Icon = SystemIcons.Exclamation, BlinkStyle = ErrorBlinkStyle.NeverBlink };
errorProvider.SetIconAlignment(panel, ErrorIconAlignment.BottomLeft);
var okButton = new Button
{
Size = new System.Drawing.Size(70, 30),
Location = new Point(330, 180),
Text = "OK"
};
okButton.Click += new EventHandler((sender, e) => { errorProvider.SetError(panel, "Test Error"); });
inputBox.Controls.Add(panel);
inputBox.Controls.Add(okButton);
return inputBox.ShowDialog();
}
答案 0 :(得分:1)
让我解释一下ErrorProvider。
ErrorProvider具有以下行为。
您想要的行为也是与图标一起显示错误消息。