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