.NET 9月21日笔记

1、文本编辑器显示多行
  textBox1.Multiline = true;
2、子窗体显示成多个数据页面
  级联this.LayoutMdi(MdiLayout.Cascade);
  水平平铺this.LayoutMdi(MdiLayout.TileHorizontal);
  数值平铺this.LayoutMdi(MdiLayout.TileVertical);
3、在子窗体中找到当前激活的窗体
  this.ActiveMdiChild;
  Form2 frm = (Form2)this.ActiveMdiChild;//强制转换成Form2
4、Delegate回调
从 InitializeComponent()中,屏蔽掉//this.button2.Click += new System.EventHandler

(this.button2_Click);
 private void button1_Click(object sender, EventArgs e)
        {
            this.button2.Click += new EventHandler(button2_Click);
//给button2的单击添加方法button2_Click,-=为去掉方法button2_Click
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("I am button2");
        }
5、验证textbox是否为空
在form1中添加一个textbox1,button1,errorProvider1
给textbox1的Validated事件添加代码
private void textBox1_Validated(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("textBox1的内容为空,请输入");
            }
        }

在form1的InitializeComponent()中,找到button1,用+=给button1的click单击事件添加方法

textBox1_Validated。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值