📄 form1.cs
字号:
namespace WinTestControl
{
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.WinForms;
using System.Data;
using WinControl;
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.WinForms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
Control1 ctrl=new Control1();
Button button1=new Button();
private System.ComponentModel.Container components;
public Form1()
{
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
this.components = new System.ComponentModel.Container ();
this.button1 = new System.WinForms.Button ();
//@this.TrayHeight = 0;
//@this.TrayLargeIcon = false;
//@this.TrayAutoArrange = true;
// New Code
EventHandler handler=new EventHandler(buttonClick);
button1.Click +=handler;
button1.Location = new System.Drawing.Point (104, 64);
button1.Size = new System.Drawing.Size (96, 72);
button1.TabIndex = 0;
button1.Text = "&Change";
button1.Visible=true;
this.Controls.Add (button1);
ctrl.Location=new System.Drawing.Point (10,10);
ctrl.Dock=DockStyle.Fill;
ctrl.Visible=true;
ctrl.Gradient2=Color.Blue;
ctrl.Gradient1=Color.Red;
this.Controls.Add(ctrl);
ctrl.OnAngleChange +=new Control1.angleChange(OnMyEvent);
// Completed code added
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
}
public override void Dispose()
{
base.Dispose();
components.Dispose();
}
public void OnMyEvent()
{
MessageBox.Show("Event Fired!");
}
private void buttonClick(object sender,EventArgs e)
{
if (sender==button1) OnMyEvent();
ctrl.Gradient1=Color.Cyan;
ctrl.Gradient2=Color.Blue;
ctrl.Refresh();
}
// public static void Main()
// {
// Form1 form1=new Form1();
// form1.ShowDialog();
// }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -