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+"°";
         特殊符号--打开搜狗--菜单--软键盘---特殊符号 选择"°"搞定。
  • 相关阅读:
    IP分片与TCP分片的考虑
    snort-2.9.16在ubuntu16.04环境下的安装,配置与运行
    snort 程序流程图
    宿主机、容器、真实时间不一致问题
    ffi动态链接库的使用
    docker容器中nginx日志的分割
    dockerFile指令详解
    关于如何查看多网卡物理机中网卡序号与物理网卡的对应该关系
    Curl相关参数意义及使用方式
    docker 基础入门
  • 原文地址:https://www.cnblogs.com/newstart/p/2856452.html
Copyright © 2011-2022 走看看