WInform 常用属性

1.获取dataGridView选择行的控件的值: dataGridView.SelectedCells[0].EditedFormattedValue.ToString()
  获取选择行某一列的值:dataGridView.CurrentRow.Cells[1].Value
  或者:dataGridView.CurrentRow.Cells["列名"].Value   (列名:是Name不是Title)

2.判断dataGridView内部checkBox的选中事件: bool check = dataGridView.Rows[0].Cells[1].Selected;

3.解决dataGridView列的顺序和自己排列的顺序不一致: this.dataGridView.AutoGenerateColumns = false;(在数据绑定前加载该属性)

4.判断dataGridView单击事件触发的是该行那一列的事件: dataGridView_CellClick或者dataGridView_CellContentClick 的事件 e.ColumnIndex == 0

5.弹出窗口的为位置设定:startposion的属性:centerscreen

6.获取DataTable第一行,第一列的值:DataTable..Rows[0].ItemArray[0].

7.获取当前登录用户的用户名: Environment.UserName

8.去掉dataGridView最后一行留白:this.dataGridView1.AllowUserToAddRows = false;

9.SQL获取今天的所有数据:select   *   from   article   where   AddTime> =convert(char(10),   getdate(),   120) and   AddTime <convert(char(10),   getdate()+1,   120)
      或者  where   convert(varchar(20),AddTime,120)=convert(varchar(20),getdate(),120)

10.获取查询语句前面的自动编号: ROW_NUMBER()OVER(ORDER BY Batch_No)  前面有个排序规则

11.当点击savefiledialog保存按钮的时候才执行 :   if (sfdFX.ShowDialog() == DialogResult.OK)  //如果点的是确定就得到文件路径

12.解决DataGridView 的下面出现被覆盖一部分的情况: Location 的 y=0, x=0

13:         DataTable roleTable  = ParameterSetter.Get_RoleInfo().Tables[0];  (设置下拉菜单的TEXT和VALUE)
            cbxRoleName.DataSource = roleTable;
            cbxRoleName.DisplayMember = "RoleName";
            cbxRoleName.ValueMember = "RoleID";

14.          //string sql = "select * from table where 1=1";
            //if(str[0].Length>0)
            //    sql += " and field1 = @field1";
            //if(str[1].Length>0)
            //    sql += " and field2 = @field2";
            //List<SqlParameter> parameters = new List<SqlParameter>();
            //if(str[0].Length>0)
            //    parameters.Add(new SqlParameter("@field1",str[0]));
            //if(str[1].Length>0)
            //    parameters.Add(new SqlParameter("@field2",str[1]));

15.当前窗口禁止拖放:this.FormBorderStyle = FormBorderStyle.FixedSingle;

16.任务栏不显示当前窗口:ShowInTaskbar=false;

17.窗体不显示最大化,最小化的按钮:FormBorderStyle=FixedDialog;

18.禁用窗体最大化最小化:MaximizeBox=false;MinimizeBox=false;


19. 验证输入必须为数字和字母的组合:if (!Regex.Match(iSINCode, @"(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{2,})$").Success)
                {
                    MessageBox.Show("ISINCode,Format is not correct !", "Message");
                    return;
                }

20. 判断验证时间为输入的数据:   WHERE datediff(dd,FXBookingDate,@DateTime)=0   (dd为验证天,MM验证月份,yyyy验证年份)

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值