zoukankan      html  css  js  c++  java
  • 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+"°";
         特殊符号--打开搜狗--菜单--软键盘---特殊符号 选择"°"搞定。
  • 相关阅读:
    win32: 静态控件(Static)
    malloc() 和 calloc()有啥区别
    win32: WM_PAINT 实现双缓冲缓图
    char 与 unsigned char的本质区别
    iconv: iconv_open(pToCharset, pFromCharset); 的附加参数//IGNORE
    c语言: 生成随机数
    深圳市住房公积金管理中心
    利用latex制作个人简历
    分布式系统概念与设计中文版(第三版)
    数据结构-红黑树
  • 原文地址:https://www.cnblogs.com/newstart/p/2856452.html
Copyright © 2011-2022 走看看