其他可以根据自己爱好设置一些,如字体,字号,窗体形状等等。
就不多说了,代码如下:
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8
9namespace BOM.NewUI.Assistant
10{
11 public partial class MessageDialog : Form
12 {
13 public MessageDialog()
14 {
15 InitializeComponent();
16 }
17
18 /// <summary>
19 /// 显示消息对话框,自行全部信息指定全部信息。
20 /// </summary>
21 /// <param name="owner">父窗口</param>
22 /// <param name="icon">显示的图标</param>
23 /// <param name="text">信息内容</param>
24 /// <param name="caption">对话框标题</param>
25 /// <param name="buttonTypes">按钮类别数组</param>
26 /// <param name="buttonLabels">按钮文字</param>
27 /// <param name="defaultButton">缺省按钮</param>
28 /// <returns>用户点击的按钮类型</returns>
29 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption,
30 DialogResult[] buttonTypes, string[] buttonLabels, DialogResult defaultButton)
31 {
32 MessageDialog dialog = new MessageDialog();
33 using (dialog)
34 {
35 dialog.SetIcon(icon);
36 dialog.SetText(text);
37 dialog.setCaption(GetCaption(icon, caption));
38 dialog.CreateButtons(buttonTypes, buttonLabels, defaultButton);
39
40 return dialog.ShowDialog(owner);
41 }
42 }
43
44 /// <summary>
45 /// 显示信息提示对话框。
46 /// </summary>
47 /// <param name="owner">父窗口</param>
48 /// <param name="text">信息内容</param>
49 /// <param name="caption">对话框标题</param>
50 /// <returns>用户点击的按钮类型</returns>
51 public static DialogResult Show(IWin32Window owner, string text, string caption)
52 {
53 return Show(owner, MessageIcon.Information, text, caption);
54 }
55
56 /// <summary>
57 /// 根据图标类型显示对话框,按钮按照图标的类型设定。
58 /// </summary>
59 /// <param name="owner">父窗口</param>
60 /// <param name="icon">图标类型</param>
61 /// <param name="text">信息内容</param>
62 /// <param name="caption">对话框标题</param>
63 /// <returns>用户点击的按钮类型</returns>
64 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption)
65 {
66 return Show(owner, icon, text, caption,
67 GetButtonTypes(icon), GetButtonLabels(icon),
68 GetDefaultButton(icon));
69 }
70
71 /// <summary>
72 /// 根据图标类型和按钮类型显示对话框。
73 /// </summary>
74 /// <param name="owner">父窗口</param>
75 /// <param name="icon">图标类型</param>
76 /// <param name="text">信息内容</param>
77 /// <param name="caption">对话框标题</param>
78 /// <param name="buttons">按钮类型,使用Windows预定义类型。</param>
79 /// <returns></returns>
80 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption,
81 MessageBoxButtons buttons)
82 {
83 return Show(owner, icon, text, caption, buttons, GetDefaultButton(buttons));
84 }
85
86 /// <summary>
87 /// 根据图标类型和按钮类型显示对话框,自行指定缺省按钮。
88 /// </summary>
89 /// <param name="owner">父窗口</param>
90 /// <param name="icon">图标类型</param>
91 /// <param name="text">信息内容</param>
92 /// <param name="caption">对话框标题</param>
93 /// <param name="buttons">按钮类型,使用Windows预定义类型。</param>
94 /// <param name="defaultButton">缺省按钮类型,点击Enter时触发</param>
95 /// <returns>用户点击的按钮类型</returns>
96 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption,
97 MessageBoxButtons buttons, DialogResult defaultButton)
98 {
99 return Show(owner, icon, text, caption, buttons, GetButtonLabels(buttons), defaultButton);
100 }
101
102 /// <summary>
103 /// 根据图标类型和按钮类型显示对话框,自行指定按钮文字和缺省按钮。
104 /// </summary>
105 /// <param name="owner">父窗口</param>
106 /// <param name="icon">图标类型</param>
107 /// <param name="text">信息内容</param>
108 /// <param name="caption">对话框标题</param>
109 /// <param name="buttons">按钮类型,使用Windows预定义类型。</param>
110 /// <param name="defaultButton">缺省按钮类型,点击Enter时触发</param>
111 /// <param name="buttonLabels">按钮文字数组</param>
112 /// <returns>用户点击的按钮类型</returns>
113 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption,
114 MessageBoxButtons buttons, string[] buttonLabels, DialogResult defaultButton)
115 {
116 return Show(owner, icon, text, caption, GetButtonTypes(buttons), buttonLabels, defaultButton);
117 }
118
119
120 private static DialogResult GetDefaultButton(MessageIcon icon)
121 {
122 switch (icon)
123 {
124 case MessageIcon.Question:
125 return DialogResult.No;
126 case MessageIcon.Password:
127 return DialogResult.OK;
128 case MessageIcon.Information:
129 case MessageIcon.Warning:
130 case MessageIcon.Error:
131 case MessageIcon.Help:
132 case MessageIcon.Locked:
133 case MessageIcon.Shutdown:
134 default:
135 return DialogResult.OK;
136 }
137 }
138
139 private static DialogResult GetDefaultButton(MessageBoxButtons buttons)
140 {
141 switch (buttons)
142 {
143 case MessageBoxButtons.YesNo:
144 return DialogResult.No;
145 case MessageBoxButtons.OKCancel:
146 return DialogResult.Cancel;
147 case MessageBoxButtons.OK:
148 return DialogResult.OK;
149 case MessageBoxButtons.AbortRetryIgnore:
150 return DialogResult.Abort;
151 case MessageBoxButtons.RetryCancel:
152 return DialogResult.Retry;
153 case MessageBoxButtons.YesNoCancel:
154 return DialogResult.Cancel;
155 default:
156 return DialogResult.OK;
157 }
158
159 }
160 /// <summary>
161 /// button 标签
162 /// </summary>
163 /// <param name="type"></param>
164 /// <returns></returns>
165 private static string GetButtonLabel(DialogResult type)
166 {
167 switch (type)
168 {
169 case DialogResult.Abort:
170 return "中止";
171 case DialogResult.Cancel:
172 return "取消";
173 case DialogResult.Ignore:
174 return "忽略";
175 case DialogResult.No:
176 return "否";
177 case DialogResult.OK:
178 return "确定";
179 case DialogResult.Retry:
180 return "重试";
181 case DialogResult.Yes:
182 return "是";
183 default:
184 return "无";
185 }
186 }
187
188 private static string[] GetButtonLabels(MessageIcon icon)
189 {
190 DialogResult[] types = GetButtonTypes(icon);
191 return GetButtonLabels(types);
192 }
193
194 private static string[] GetButtonLabels(MessageBoxButtons buttons)
195 {
196 DialogResult[] types = GetButtonTypes(buttons);
197 return GetButtonLabels(types);
198 }
199
200 private static string[] GetButtonLabels(DialogResult[] types)
201 {
202 string[] labels = new string[types.Length];
203 for (int i = 0; i < types.Length; i++)
204 {
205 labels[i] = GetButtonLabel(types[i]);
206 }
207
208 return labels;
209 }
210
211 private static DialogResult[] BUTTON_TYPES_ABORT_RETRY_CANCEL = new DialogResult[]
212 {
213 DialogResult.Abort,
214 DialogResult.Retry,
215 DialogResult.Ignore,
216 };
217
218 private static DialogResult[] BUTTON_TYPES_OK = new DialogResult[]
219 {
220 DialogResult.OK,
221 };
222
223 private static DialogResult[] BUTTON_TYPES_OK_CANCEL = new DialogResult[]
224 {
225 DialogResult.OK, DialogResult.Cancel,
226 };
227
228 private static DialogResult[] BUTTON_TYPES_RETRY_CANCEL = new DialogResult[]
229 {
230 DialogResult.Retry, DialogResult.Cancel,
231 };
232
233 private static DialogResult[] BUTTON_TYPES_YES_NO = new DialogResult[]
234 {
235 DialogResult.Yes, DialogResult.No,
236 };
237
238 private static DialogResult[] BUTTON_TYPES_YES_NO_CANCEL = new DialogResult[]
239 {
240 DialogResult.Yes, DialogResult.No, DialogResult.Cancel,
241 };
242
243 private static DialogResult[] GetButtonTypes(MessageIcon icon)
244 {
245 switch (icon)
246 {
247 case MessageIcon.Question:
248 return BUTTON_TYPES_YES_NO;
249 case MessageIcon.Password:
250 return BUTTON_TYPES_OK_CANCEL;
251 case MessageIcon.Information:
252 case MessageIcon.Warning:
253 case MessageIcon.Error:
254 case MessageIcon.Help:
255 case MessageIcon.Locked:
256 case MessageIcon.Shutdown:
257 default:
258 return BUTTON_TYPES_OK;
259 }
260 }
261
262
263 private static DialogResult[] GetButtonTypes(MessageBoxButtons buttons)
264 {
265 switch (buttons)
266 {
267 case MessageBoxButtons.YesNo:
268 return BUTTON_TYPES_YES_NO;
269 case MessageBoxButtons.OKCancel:
270 return BUTTON_TYPES_OK_CANCEL;
271 case MessageBoxButtons.OK:
272 return BUTTON_TYPES_OK;
273 case MessageBoxButtons.AbortRetryIgnore:
274 return BUTTON_TYPES_ABORT_RETRY_CANCEL;
275 case MessageBoxButtons.RetryCancel:
276 return BUTTON_TYPES_RETRY_CANCEL;
277 case MessageBoxButtons.YesNoCancel:
278 return BUTTON_TYPES_YES_NO_CANCEL;
279 default:
280 return BUTTON_TYPES_OK;
281 }
282 }
283
284
285 private static string[] CAPTIONS = new string[]
286 {
287 "提示",
288 "请确认操作",
289 "警告",
290 "错误",
291 "操作中止",
292 "帮助信息",
293 "已锁定",
294 "安全信息",
295 "系统关闭"
296 };
297
298 private static string GetCaption(MessageIcon icon, string caption)
299 {
300 if (!string.IsNullOrEmpty(caption))
301 return caption;
302
303 return CAPTIONS[(int)icon];
304 }
305
306
307 private void SetIcon(MessageIcon icon)
308 {
309 iconBox.Image = iconList.Images[(int)icon];
310 }
311
312 private void SetText(string text)
313 {
314 textLabel.Text = text;
315 }
316
317 private void setCaption(string caption)
318 {
319 Text = caption;
320 }
321
322 private const int BUTTON_POSITION_Y = 230;
323 private const int BUTTON_GAP = 40;
324 private static Size BUTTON_SIZE = new Size(100, 30);
325
326 /// <summary>
327 /// 创建Button。
328 /// </summary>
329 /// <param name="types"></param>
330 /// <param name="labels"></param>
331 /// <param name="dft"></param>
332 private void CreateButtons(DialogResult[] types, string[] labels, DialogResult dft)
333 {
334 int count = types.Length;
335 int x = (Size.Width - (count * BUTTON_SIZE.Width + (count - 1) * BUTTON_GAP)) / 2;
336 for (int i = 0; i < types.Length; i++)
337 {
338 DialogResult type = types[i];
339 Button button = new Button();
340
341 button.Location = new Point(x + i * (BUTTON_SIZE.Width + BUTTON_GAP), BUTTON_POSITION_Y);
342 button.Size = BUTTON_SIZE;
343 button.DialogResult = type;
344 button.Text = labels[i];
345 Controls.Add(button);
346
347 if (type == dft)
348 {
349 AcceptButton = button;
350 }
351 }
352 }
353 }
354
355
356 /// <summary>
357 /// 用于枚举消息对话框使用的图标。
358 /// </summary>
359 public enum MessageIcon : int
360 {
361 /// <summary>
362 /// 提示信息。
363 /// </summary>
364 Information = 0,
365 /// <summary>
366 /// 需要用户确认。
367 /// </summary>
368 Question = 1,
369 /// <summary>
370 /// 警告信息。
371 /// </summary>
372 Warning = 2,
373 /// <summary>
374 /// 错误信息。
375 /// </summary>
376 Error = 3,
377 /// <summary>
378 /// 操作终止,或被禁止的提示信息。
379 /// </summary>
380 Stop = 4,
381 /// <summary>
382 /// 帮助信息。
383 /// </summary>
384 Help = 5,
385 /// <summary>
386 /// 已锁定信息。
387 /// </summary>
388 Locked = 6,
389 /// <summary>
390 /// 密码,安全相关信息。
391 /// </summary>
392 Password = 7,
393 /// <summary>
394 /// 关闭提示信息。
395 /// </summary>
396 Shutdown = 8
397 }
398}
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8
9namespace BOM.NewUI.Assistant
10{
11 public partial class MessageDialog : Form
12 {
13 public MessageDialog()
14 {
15 InitializeComponent();
16 }
17
18 /// <summary>
19 /// 显示消息对话框,自行全部信息指定全部信息。
20 /// </summary>
21 /// <param name="owner">父窗口</param>
22 /// <param name="icon">显示的图标</param>
23 /// <param name="text">信息内容</param>
24 /// <param name="caption">对话框标题</param>
25 /// <param name="buttonTypes">按钮类别数组</param>
26 /// <param name="buttonLabels">按钮文字</param>
27 /// <param name="defaultButton">缺省按钮</param>
28 /// <returns>用户点击的按钮类型</returns>
29 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption,
30 DialogResult[] buttonTypes, string[] buttonLabels, DialogResult defaultButton)
31 {
32 MessageDialog dialog = new MessageDialog();
33 using (dialog)
34 {
35 dialog.SetIcon(icon);
36 dialog.SetText(text);
37 dialog.setCaption(GetCaption(icon, caption));
38 dialog.CreateButtons(buttonTypes, buttonLabels, defaultButton);
39
40 return dialog.ShowDialog(owner);
41 }
42 }
43
44 /// <summary>
45 /// 显示信息提示对话框。
46 /// </summary>
47 /// <param name="owner">父窗口</param>
48 /// <param name="text">信息内容</param>
49 /// <param name="caption">对话框标题</param>
50 /// <returns>用户点击的按钮类型</returns>
51 public static DialogResult Show(IWin32Window owner, string text, string caption)
52 {
53 return Show(owner, MessageIcon.Information, text, caption);
54 }
55
56 /// <summary>
57 /// 根据图标类型显示对话框,按钮按照图标的类型设定。
58 /// </summary>
59 /// <param name="owner">父窗口</param>
60 /// <param name="icon">图标类型</param>
61 /// <param name="text">信息内容</param>
62 /// <param name="caption">对话框标题</param>
63 /// <returns>用户点击的按钮类型</returns>
64 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption)
65 {
66 return Show(owner, icon, text, caption,
67 GetButtonTypes(icon), GetButtonLabels(icon),
68 GetDefaultButton(icon));
69 }
70
71 /// <summary>
72 /// 根据图标类型和按钮类型显示对话框。
73 /// </summary>
74 /// <param name="owner">父窗口</param>
75 /// <param name="icon">图标类型</param>
76 /// <param name="text">信息内容</param>
77 /// <param name="caption">对话框标题</param>
78 /// <param name="buttons">按钮类型,使用Windows预定义类型。</param>
79 /// <returns></returns>
80 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption,
81 MessageBoxButtons buttons)
82 {
83 return Show(owner, icon, text, caption, buttons, GetDefaultButton(buttons));
84 }
85
86 /// <summary>
87 /// 根据图标类型和按钮类型显示对话框,自行指定缺省按钮。
88 /// </summary>
89 /// <param name="owner">父窗口</param>
90 /// <param name="icon">图标类型</param>
91 /// <param name="text">信息内容</param>
92 /// <param name="caption">对话框标题</param>
93 /// <param name="buttons">按钮类型,使用Windows预定义类型。</param>
94 /// <param name="defaultButton">缺省按钮类型,点击Enter时触发</param>
95 /// <returns>用户点击的按钮类型</returns>
96 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption,
97 MessageBoxButtons buttons, DialogResult defaultButton)
98 {
99 return Show(owner, icon, text, caption, buttons, GetButtonLabels(buttons), defaultButton);
100 }
101
102 /// <summary>
103 /// 根据图标类型和按钮类型显示对话框,自行指定按钮文字和缺省按钮。
104 /// </summary>
105 /// <param name="owner">父窗口</param>
106 /// <param name="icon">图标类型</param>
107 /// <param name="text">信息内容</param>
108 /// <param name="caption">对话框标题</param>
109 /// <param name="buttons">按钮类型,使用Windows预定义类型。</param>
110 /// <param name="defaultButton">缺省按钮类型,点击Enter时触发</param>
111 /// <param name="buttonLabels">按钮文字数组</param>
112 /// <returns>用户点击的按钮类型</returns>
113 public static DialogResult Show(IWin32Window owner, MessageIcon icon, string text, string caption,
114 MessageBoxButtons buttons, string[] buttonLabels, DialogResult defaultButton)
115 {
116 return Show(owner, icon, text, caption, GetButtonTypes(buttons), buttonLabels, defaultButton);
117 }
118
119
120 private static DialogResult GetDefaultButton(MessageIcon icon)
121 {
122 switch (icon)
123 {
124 case MessageIcon.Question:
125 return DialogResult.No;
126 case MessageIcon.Password:
127 return DialogResult.OK;
128 case MessageIcon.Information:
129 case MessageIcon.Warning:
130 case MessageIcon.Error:
131 case MessageIcon.Help:
132 case MessageIcon.Locked:
133 case MessageIcon.Shutdown:
134 default:
135 return DialogResult.OK;
136 }
137 }
138
139 private static DialogResult GetDefaultButton(MessageBoxButtons buttons)
140 {
141 switch (buttons)
142 {
143 case MessageBoxButtons.YesNo:
144 return DialogResult.No;
145 case MessageBoxButtons.OKCancel:
146 return DialogResult.Cancel;
147 case MessageBoxButtons.OK:
148 return DialogResult.OK;
149 case MessageBoxButtons.AbortRetryIgnore:
150 return DialogResult.Abort;
151 case MessageBoxButtons.RetryCancel:
152 return DialogResult.Retry;
153 case MessageBoxButtons.YesNoCancel:
154 return DialogResult.Cancel;
155 default:
156 return DialogResult.OK;
157 }
158
159 }
160 /// <summary>
161 /// button 标签
162 /// </summary>
163 /// <param name="type"></param>
164 /// <returns></returns>
165 private static string GetButtonLabel(DialogResult type)
166 {
167 switch (type)
168 {
169 case DialogResult.Abort:
170 return "中止";
171 case DialogResult.Cancel:
172 return "取消";
173 case DialogResult.Ignore:
174 return "忽略";
175 case DialogResult.No:
176 return "否";
177 case DialogResult.OK:
178 return "确定";
179 case DialogResult.Retry:
180 return "重试";
181 case DialogResult.Yes:
182 return "是";
183 default:
184 return "无";
185 }
186 }
187
188 private static string[] GetButtonLabels(MessageIcon icon)
189 {
190 DialogResult[] types = GetButtonTypes(icon);
191 return GetButtonLabels(types);
192 }
193
194 private static string[] GetButtonLabels(MessageBoxButtons buttons)
195 {
196 DialogResult[] types = GetButtonTypes(buttons);
197 return GetButtonLabels(types);
198 }
199
200 private static string[] GetButtonLabels(DialogResult[] types)
201 {
202 string[] labels = new string[types.Length];
203 for (int i = 0; i < types.Length; i++)
204 {
205 labels[i] = GetButtonLabel(types[i]);
206 }
207
208 return labels;
209 }
210
211 private static DialogResult[] BUTTON_TYPES_ABORT_RETRY_CANCEL = new DialogResult[]
212 {
213 DialogResult.Abort,
214 DialogResult.Retry,
215 DialogResult.Ignore,
216 };
217
218 private static DialogResult[] BUTTON_TYPES_OK = new DialogResult[]
219 {
220 DialogResult.OK,
221 };
222
223 private static DialogResult[] BUTTON_TYPES_OK_CANCEL = new DialogResult[]
224 {
225 DialogResult.OK, DialogResult.Cancel,
226 };
227
228 private static DialogResult[] BUTTON_TYPES_RETRY_CANCEL = new DialogResult[]
229 {
230 DialogResult.Retry, DialogResult.Cancel,
231 };
232
233 private static DialogResult[] BUTTON_TYPES_YES_NO = new DialogResult[]
234 {
235 DialogResult.Yes, DialogResult.No,
236 };
237
238 private static DialogResult[] BUTTON_TYPES_YES_NO_CANCEL = new DialogResult[]
239 {
240 DialogResult.Yes, DialogResult.No, DialogResult.Cancel,
241 };
242
243 private static DialogResult[] GetButtonTypes(MessageIcon icon)
244 {
245 switch (icon)
246 {
247 case MessageIcon.Question:
248 return BUTTON_TYPES_YES_NO;
249 case MessageIcon.Password:
250 return BUTTON_TYPES_OK_CANCEL;
251 case MessageIcon.Information:
252 case MessageIcon.Warning:
253 case MessageIcon.Error:
254 case MessageIcon.Help:
255 case MessageIcon.Locked:
256 case MessageIcon.Shutdown:
257 default:
258 return BUTTON_TYPES_OK;
259 }
260 }
261
262
263 private static DialogResult[] GetButtonTypes(MessageBoxButtons buttons)
264 {
265 switch (buttons)
266 {
267 case MessageBoxButtons.YesNo:
268 return BUTTON_TYPES_YES_NO;
269 case MessageBoxButtons.OKCancel:
270 return BUTTON_TYPES_OK_CANCEL;
271 case MessageBoxButtons.OK:
272 return BUTTON_TYPES_OK;
273 case MessageBoxButtons.AbortRetryIgnore:
274 return BUTTON_TYPES_ABORT_RETRY_CANCEL;
275 case MessageBoxButtons.RetryCancel:
276 return BUTTON_TYPES_RETRY_CANCEL;
277 case MessageBoxButtons.YesNoCancel:
278 return BUTTON_TYPES_YES_NO_CANCEL;
279 default:
280 return BUTTON_TYPES_OK;
281 }
282 }
283
284
285 private static string[] CAPTIONS = new string[]
286 {
287 "提示",
288 "请确认操作",
289 "警告",
290 "错误",
291 "操作中止",
292 "帮助信息",
293 "已锁定",
294 "安全信息",
295 "系统关闭"
296 };
297
298 private static string GetCaption(MessageIcon icon, string caption)
299 {
300 if (!string.IsNullOrEmpty(caption))
301 return caption;
302
303 return CAPTIONS[(int)icon];
304 }
305
306
307 private void SetIcon(MessageIcon icon)
308 {
309 iconBox.Image = iconList.Images[(int)icon];
310 }
311
312 private void SetText(string text)
313 {
314 textLabel.Text = text;
315 }
316
317 private void setCaption(string caption)
318 {
319 Text = caption;
320 }
321
322 private const int BUTTON_POSITION_Y = 230;
323 private const int BUTTON_GAP = 40;
324 private static Size BUTTON_SIZE = new Size(100, 30);
325
326 /// <summary>
327 /// 创建Button。
328 /// </summary>
329 /// <param name="types"></param>
330 /// <param name="labels"></param>
331 /// <param name="dft"></param>
332 private void CreateButtons(DialogResult[] types, string[] labels, DialogResult dft)
333 {
334 int count = types.Length;
335 int x = (Size.Width - (count * BUTTON_SIZE.Width + (count - 1) * BUTTON_GAP)) / 2;
336 for (int i = 0; i < types.Length; i++)
337 {
338 DialogResult type = types[i];
339 Button button = new Button();
340
341 button.Location = new Point(x + i * (BUTTON_SIZE.Width + BUTTON_GAP), BUTTON_POSITION_Y);
342 button.Size = BUTTON_SIZE;
343 button.DialogResult = type;
344 button.Text = labels[i];
345 Controls.Add(button);
346
347 if (type == dft)
348 {
349 AcceptButton = button;
350 }
351 }
352 }
353 }
354
355
356 /// <summary>
357 /// 用于枚举消息对话框使用的图标。
358 /// </summary>
359 public enum MessageIcon : int
360 {
361 /// <summary>
362 /// 提示信息。
363 /// </summary>
364 Information = 0,
365 /// <summary>
366 /// 需要用户确认。
367 /// </summary>
368 Question = 1,
369 /// <summary>
370 /// 警告信息。
371 /// </summary>
372 Warning = 2,
373 /// <summary>
374 /// 错误信息。
375 /// </summary>
376 Error = 3,
377 /// <summary>
378 /// 操作终止,或被禁止的提示信息。
379 /// </summary>
380 Stop = 4,
381 /// <summary>
382 /// 帮助信息。
383 /// </summary>
384 Help = 5,
385 /// <summary>
386 /// 已锁定信息。
387 /// </summary>
388 Locked = 6,
389 /// <summary>
390 /// 密码,安全相关信息。
391 /// </summary>
392 Password = 7,
393 /// <summary>
394 /// 关闭提示信息。
395 /// </summary>
396 Shutdown = 8
397 }
398}
使用时可如下方式:
MessageDialog.Show(this, MessageIcon.Question, "中国*****技术服务公司", "提示信息", MessageBoxButtons.YesNo);
MessageDialog.Show(this, MessageIcon.Locked, "中国*****技术服务公司", "提示信息", MessageBoxButtons.YesNo);
MessageDialog.Show(this, MessageIcon.Shutdown, "中国*****技术服务公司", "提示信息", MessageBoxButtons.YesNo);
MessageDialog.Show(this, MessageIcon.Stop, "中国*****技术服务公司", "提示信息", MessageBoxButtons.YesNo);
MessageDialog.Show(this, MessageIcon.Help, "中国*****技术服务公司", "提示信息", MessageBoxButtons.YesNo);