1、Button類c++
表示 Windows 按鈕控件。c#
繼承層次結構:
ide
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ButtonBase
System.Windows.Forms.Button函數
1.構造函數spa
[c#] public Button()
[c++] public:
Button()
[vb] Private Sub InitializeMyButton() 'InitializeMyButton
Dim button1 As New Button() ' Create and initialize a Button.
End Sub.net
2.屬性指針
AutoEllipsis 獲取或設置一個值,該值指示是否要在控件的右邊緣顯示省略號 (...) 以表示控件文本超出指定的控件長度。 (繼承自 ButtonBase。) 默認狀況下超出的文字不會顯示orm
AutoSize 獲取或設置一個值,該值指示控件是否基於其內容調整大小。(繼承自ButtonBase。)默認爲false,該屬性與AutoEllipsis屬性同時使用會有干擾。blog
BackColor 獲取或設置控件的背景色。 (繼承自 ButtonBase。)繼承
Bottom 獲取控件下邊緣與其容器的工做區上邊緣之間的距離(以像素爲單位)。 (繼承自 Control。)
CanFocus 獲取一個值,該值指示控件是否能夠接收焦點。 (繼承自 Control。)
Created 獲取一個值,該值指示控件是否已經建立。 (繼承自 Control。)
Cursor 獲取或設置當鼠標指針位於控件上時顯示的光標。 (繼承自 Control。)
DefaultCursor 獲取或設置控件的默認光標。 (繼承自 Control。)
DefaultMargin 獲取控件之間默認指定的間距(以像素爲單位)。 (繼承自 Control。)
Text 獲取或設置與此控件關聯的文本。 (繼承自 ButtonBase。)
舉例:創建一個C#的Windows窗體應用程序,以下圖:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
button1.Text = "肯定肯定肯定肯定肯定肯定";
button1.BackColor = Color.Blue;
Form myform = button1.FindForm();
myform.Text = "The Form Of My Control";
myform.BackColor = Color.Red;
//button1.AutoEllipsis = true;
button1.AutoSize = true;
button1.Text = button1.Bottom.ToString(); //int轉型爲string
}
}
}
注:C#程序代碼中字符串使用雙引號,語句以分號結束;
System.Drawing.Color表示一種ARGB顏色(alpha、紅色、綠色、藍色);
Color Color.Blue 獲取ARGB值爲#FF0000FF的系統定義的顏色
.net開發的Excel http://bbs.csdn.net/topics/390775539