先来个图片:
再上代码
![ContractedBlock.gif](http://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> 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
{
///
/// 构造函数
///
public CloseForm()
{
InitializeComponent();
this .DialogResult = DialogResult.Cancel;
}
///
/// 确定按钮点击事件
///
///
///
private void button1_Click( object sender, EventArgs e)
{
if (radioButton1.Checked)
{
this .DialogResult = DialogResult.OK;
}
else
{
this .DialogResult = DialogResult.No;
}
this .Close();
}
///
/// 绘图事件
///
///
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Icon icon = SystemIcons.Question;
g.DrawIcon(icon, 30 , 16 );
}
///
/// 取消按钮点击事件
///
///
///
private void button2_Click( object sender, EventArgs e)
{
this .Close();
}
}
}
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> 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
{
///
/// 构造函数
///
public CloseForm()
{
InitializeComponent();
this .DialogResult = DialogResult.Cancel;
}
///
/// 确定按钮点击事件
///
///
///
private void button1_Click( object sender, EventArgs e)
{
if (radioButton1.Checked)
{
this .DialogResult = DialogResult.OK;
}
else
{
this .DialogResult = DialogResult.No;
}
this .Close();
}
///
/// 绘图事件
///
///
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Icon icon = SystemIcons.Question;
g.DrawIcon(icon, 30 , 16 );
}
///
/// 取消按钮点击事件
///
///
///
private void button2_Click( object sender, EventArgs e)
{
this .Close();
}
}
}
其中绘图事件的代码比较重要
全靠这两句代码让这个窗体有了系统icon资源
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12639172/viewspace-622489/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12639172/viewspace-622489/