国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

Button控件Location屬性的使用方法

2023-05-10 18:49:24
字體:
來源:轉載
供稿:網友

本程序演示了C#中Button控件的使用方法,本程序首先創建了一個按鈕(Button)控件,并使用Location屬性給其定位,并且在程序中為該控件指定了單擊事件處理程序。

注:本程序轉自一個國外的網站(http://www.java2s.com),轉載時經過了適當修改。

using System;
using System.Drawing;
using System.Windows.Forms;
   
class SimpleButton: Form
{
     public static void Main()
     {
          Application.Run(new SimpleButton());
     }
     public SimpleButton()
     {
          Text = "演示Button控件Location屬性的使用方法";
   
          Button btn   = new Button();
          btn.Parent   = this;
          btn.Text     = "單擊我!";
          btn.Location = new Point(100100);
          btn.Click   += new EventHandler(ButtonOnClick);
     }
     void ButtonOnClick(object obj, EventArgs ea)
     {
          Graphics grfx   = CreateGraphics();
          Point    ptText = Point.Empty;
          string   str    = "你點擊了按鈕!";
   
          grfx.DrawString(str, Font, new SolidBrush(ForeColor), ptText);
          grfx.Dispose();
     }
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 同德县| 仲巴县| 岳普湖县| 当阳市| 广平县| SHOW| 紫阳县| 抚远县| 陆丰市| 伊吾县| 四川省| 烟台市| 镇康县| 堆龙德庆县| 曲阳县| 任丘市| 德阳市| 托克托县| 汾阳市| 云霄县| 原平市| 永清县| 陆川县| 循化| 绍兴市| 芦山县| 红河县| 横山县| 乌苏市| 天津市| 辉县市| 峨眉山市| 甘德县| 革吉县| 易门县| 兰考县| 临猗县| 辽宁省| 扎兰屯市| 海门市| 章丘市|