windowsform on C#
Home  Contents KMArticlesMembersSponsorsAbout us

ปรับปรุง : 2557-11-08 (เรียบเรียงใหม่)
โปรแกรมแรก : สร้าง button ผ่าน runtime ใน C#
ขั้นตอน 
1. เปิด windows form จะได้ form1.cs
2. double click บน form เข้าสู่การ coding 
3. ใช้ code ดังนี้
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;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
public Form1() {
  InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
  Button myButton = new Button();
  myButton.Height = 40;
  myButton.Width = 200;
  myButton.BackColor = Color.Yellow;
  myButton.ForeColor = Color.Blue;
  myButton.Location = new Point(5, 100);
  myButton.Text = "I am Dynamic Button";
  myButton.Name = "myButton";
  myButton.Font = new Font("arial", 12);
  myButton.Click += new EventHandler(myButton_Click);
  Controls.Add(myButton);
}
private void myButton_Click(object sender, EventArgs e) {
  MessageBox.Show("hello");
}
}
}
// http://www.c-sharpcorner.com/uploadfile/mahesh/creating-a-button-at-run-time-in-C-Sharp/
"Imagination is more important than knowledge" - Albert Einstein
Home
Thaiabc.com
Thainame.net
Lampang.net
Nation university
PHP
MySQL
Visual basic.NET
TabletPC
Linux
Online quiz
Download
Search engine
Web ranking
Add website
Blog : Education
Blog : ACLA
Blog : Lampang
Facebook.com
Twitter.com
About us
My dream
Site map
Sponsor