• c# 操作技巧


    一直以来很多细节都没有记录,现在要注意了好记性不如烂笔头,你懂的

    1、(winform)中C# 怎样判断 datagridview  中的checkbox列是否被选中

         for (int i = 0; i < dataGridView1.Rows.Count; i++)
         {
               if  ((bool)dataGridView1.Rows[i].Cells[0].EditedFormattedValue==true)
                {
                        //TODO
                 }                 
         }

    2、datagridview  中的checkbox列全选操作 

         private void CheckAll_CheckedChanged(object sender, EventArgs e)
        {
             if (dataGridView1.Rows.Count > 0)
              {
                   for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
                   {
                       dataGridView1.Rows(i).Cells(0).Value = true;
                   }
               }
         }
    3、datagridview  中的checkbox列反选
        private void CheckReverse_CheckedChanged(object sender, EventArgs e)
       {
             if (dataGridView1.Rows.Count > 0)
              {
                 for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
                 {
                      if (Convert.ToBoolean(dataGridView1.Rows(i).Cells(0).EditedFormattedValue))
                      {
                          dataGridView1.Rows(i).Cells(0).Value = false;
                      }
                      else
                    {
                         dataGridView1.Rows(i).Cells(0).Value = true;
                     }
                }
             }
         }
    4、c#保留小数点后2位
         double dbdata = 0.55555;
         string str1 = dbdata.ToString("f2");//fN 保留N位,四舍五入
         string str1 = String.Format("{0:N2}", 5.6789); //result: 56,789.0
    5、c#显示角度符号
         string str1 = String.Format("{0:N2}", 5.6789); //result: 56,789.0
         textBox1.Text = str1+"°";
         特殊符号--打开搜狗--菜单--软键盘---特殊符号 选择"°"搞定。
  • 相关阅读:
    MaxScript 计算执行时间差
    MaxScript 几种类GUID的生成方法
    MaxScript 防坑规范指南
    样式测试
    设置.MAX文件程序关联
    Python相关网站(持续更新)
    Python程序使用cx_freeze打包(报错)
    Python对Excel的操作(模块win32com)
    Python对Excel的操作(模块xlrd)
    python模块安装
  • 原文地址:https://www.cnblogs.com/newstart/p/2856452.html
Copyright © 2020-2023  润新知