英文:
related to question: show message after a successful record saving
问题
我想要显示一个消息,只有在保存了一个新对象之后才会显示,并在其他记录保存情况下隐藏它,如何做到这一点?
英文:
I have been read the answer for the question written in the following link: https://stackoverflow.com/questions/69046380/show-message-after-a-successful-record-saving/69055284#69055284
The solution was very useful, but my question is: If I want to show a message only after a new object is saved, and hide it in other record saving cases, How to do that?
答案1
得分: 0
你可以像下面这样做。如果事件不是你要查找的事件类型,你就不设置消息。如果消息为null或为空,就不显示它。
void ObjectSpace_Committed(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(message))
{
MessageOptions options = new();
options.Duration = 2000;
options.Message = message;
options.Type = InformationType.Success;
options.Web.Position = InformationPosition.Right;
options.Win.Caption = "Success";
options.Win.Type = WinMessageType.Toast;
Application.ShowViewStrategy.ShowMessage(options);
message = string.Empty;
}
}
void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e)
{
if (ObjectSpace.IsNewObject(e.Object))
{
message = string.Format("Record Saved Successfully");
}
}
英文:
You could do something like the below. If the event is not the event type you are looking for, you just don't set the message. And if the message is null or empty, you don't show it.
void ObjectSpace_Committed(object sender, EventArgs e)
{
if (!string.IsNullOrEMpty(message))
{
MessageOptions options = new();
options.Duration = 2000;
options.Message = message;
options.Type = InformationType.Success;
options.Web.Position = InformationPosition.Right;
options.Win.Caption = "Success";
options.Win.Type = WinMessageType.Toast;
Application.ShowViewStrategy.ShowMessage(options);
message = string.Empty;
}
}
void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e)
{
if (ObjectSpace.IsNewObject(e.Object))
{
message=string.Format("Record Saved Successfully");
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论