C#(winform)项目中自制alert提示窗体并引用系统图标资源

先来个图片:

C#(winform)项目中自制alert提示窗体并引用系统图标资源

再上代码

C#(winform)项目中自制alert提示窗体并引用系统图标资源C#(winform)项目中自制alert提示窗体并引用系统图标资源代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;


namespace FB.FormHelper
{
public partial class CloseForm : Form
{
/// <summary>
/// 构造函数
/// </summary>
public CloseForm()
{
InitializeComponent();
this.DialogResult = DialogResult.Cancel;
}
/// <summary>
/// 确定按钮点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
this.DialogResult = DialogResult.OK;
}
else
{
this.DialogResult = DialogResult.No;
}
this.Close();
}
/// <summary>
/// 绘图事件
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
Graphics g
= e.Graphics;
Icon icon
= SystemIcons.Question;
g.DrawIcon(icon,
30, 16);
}
/// <summary>
/// 取消按钮点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}

}
}

其中绘图事件的代码比较重要

全靠这两句代码让这个窗体有了系统icon资源

上一篇:Cookies的SameSite属性


下一篇:Flask中session和cookies的使用