在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
类型转换; 显示转换,隐式转换 显示转换:注意数据是否益处 checked(expression) unchecked(expression);//可以改变益出检查的默认设置 枚举转换 Ex: static void Main(string[] args) { string str = "noth"; test t = (test)Enum.Parse(typeof(test), str); } enum test { noth, noth1 } 控件添加:
private void button1_Click(object sender, EventArgs e) { ((Button)sender).Text = "Clicked"; Button button = new Button(); button.Text = "按钮"; button.Size = new Size(100, 30);//控件大小 button.Location = new Point(0, 0); //位置 button.Click += delegate { ButtonClick(); }; //新控件增加执行的方法 this.Controls.Add(button); } void ButtonClick() //方法 { MessageBox.Show("点击了click事件"); }
((Button)sender).Text = "Clicked"; //Button bt = new Button(); Button bt = new Button(); bt.Location = new Point(20, 60); bt.Text = "New Button"; //t.Click += new EventHandler(bt_Click); bt.Click += new EventHandler(bt_Click); Controls.Add(bt); } void bt_Click(object sender, EventArgs e) { //((Button)sender).Text = "Hello"; MessageBox.Show("HelloWord"); } DataBinding使用: ex:案例:http://www.cnblogs.com/scy251147/archive/2011/10/23/2221991.html private void button1_Click(object sender, EventArgs e) { Person p = new Person(); p.MyValue="Hello"; textBox1.DataBindings.Add("text", p, "MyValue", false, DataSourceUpdateMode.OnPropertyChanged); } } class Person { public string MyValue { get; set; } } 解释: /************************************************
|
请发表评论