errorProvider.SetError(control, message)
to display the message, but only the Icon
is shown, the message is not shown, what is wrong?Is there a way to adjust the left margin of the error message only? (I know you can SetIconPadding
, but I only want left margin to be changed)
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();
}
Let me explain about ErrorProvider.
ErrorProvider in Windows Application has following behaviour.
The behaviour you want is too display error message along with icon.