private void tbName_Validating(object sender, EventArgs e) { bool cancel = false; if (string.IsNullOrWhiteSpace(tbName.Text) && SupplementNames.Length > 0) { cancel = true; MessageDialog md = new MessageDialog(MainWidget.Toplevel as Window, DialogFlags.Modal, MessageType.Warning, ButtonsType.Ok, "You must provide a name for the supplement"); md.Title = "Invalid entry"; md.Run(); md.Destroy(); } if (!cancel) { if (SuppAttrChanged != null) { TStringArgs args = new TStringArgs(); args.name = tbName.Text; if (SuppNameChanged != null) { SuppNameChanged.Invoke(sender, args); } } } }
private void tbName_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrWhiteSpace(tbName.Text)) { e.Cancel = true; MessageBox.Show(String.Format("You must provide a name for the supplement")); } if (!e.Cancel && tbName.Modified) { if (SuppAttrChanged != null) { TStringArgs args = new TStringArgs(); args.name = tbName.Text; SuppNameChanged.Invoke(sender, args); tbName.Modified = false; } } }