C#笔记

一、给窗体加载监听事件方法:

 

    1、选中窗体更改其属性 keyPreview True

    2、到窗体 KeyDown 事件写入代码 如:

 

         if (e.KeyCode == Keys.Escape )

            {

                this.Close();

            }

注意:Keys.Escape 中的 Escape 可是键盘上的任意一个键

 

 

 

二、鼠标单击 button 弹出下拉菜单方法:

 

   1、增加 ContextMenuStrip 控件 并增添其下拉要显示的菜单 

   2、给 button MouseClike 事件写入代码 如:

   

        if (e.Button == System.Windows.Forms.MouseButtons.Left)

            {

                cms_out2.Show(MousePosition);

            }

 

 

 

三、ADO.NET 处理多条件的查询SQL语句的处理( where 1=1

 

string sSql = "select ID, FlightNO, LeaveCity, Destination, LeaveTime"

                +" from TicketInfo where 1=1";

 

            if (txtSearchFrom.Text.Trim() != "")

            {

                sSql += string.Format(" And LeaveCity like '%{0}%'", txtSearchFrom.Text.Trim());

            }

 

            if (txtSearchTo.Text.Trim() != "")

            {

                sSql += string.Format(" And Destination like '%{0}%'", txtSearchTo.Text.Trim());

            }

 



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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值