• C#DataGrdviewl加入checkBox全选删除


            #region 加入checkBox
            /// <summary>
            /// 加入checkBox
            /// </summary>
            /// <param name="datagridview"></param>
            private void chekBox(DataGridView datagridview)
            {
                DataGridViewCheckBoxColumn newColumn = new DataGridViewCheckBoxColumn();//添加CHECKBOX
                newColumn.HeaderText = "选择";
                datagridview.Columns.Insert(0, newColumn);
                datagridview.MultiSelect = true;
                newColumn.InheritedStyle.Alignment = DataGridViewContentAlignment.TopCenter;
                newColumn.Width = 35;
                datagridview.VirtualMode = false;
            }
            #endregion
    
    
    
       //dataGrvieCheckBox是否全选
            private void dataGrviesCheckBoxIsFT(CheckBox checkbox, DataGridView datagridview)
            {
                if (checkbox.Checked == true)
                {
                    if (datagridview.Rows.Count > 0)
                    {
                        for (int i = 0; i < datagridview.Rows.Count; i++)
                        {
    
                            ((DataGridViewCheckBoxCell)datagridview.Rows[i].Cells[0]).Value = true;
                        }
                    }
                }
                else
                {
                    if (datagridview.Rows.Count > 0)
                    {
                        for (int i = 0; i < datagridview.Rows.Count; i++)
                        {
                            ((DataGridViewCheckBoxCell)datagridview.Rows[i].Cells[0]).Value = false;
                        }
                    }
                }
            }
    
    
    
    
            //选中删除的记录
            private void button15_Click(object sender, EventArgs e)
            {
                if (dataFssb.Rows.Count > 0)
                {
                    for (int i = 0; i < dataFssb.Rows.Count; i++)
                    {
                        string _selectValue = dataFssb.Rows[i].Cells[0].EditedFormattedValue.ToString();
                        if (_selectValue == "True")
                        {
                            //MessageBox.Show(dataGridView2.Rows[i].Cells["fsmx_no"].Value.ToString());
                            sqlhelpers.ExecuteNonQuery("delete from dxpt_Fsmx where fsmx_no=" + dataFssb.Rows[i].Cells["fsmx_no1"].Value.ToString() + "");
    
                        }
                    }
                }
    
                this.dataFssb.DataSource = sqlhelpers.datatable("select rwlb,wczt,zdsjhm,fsnr,cjsj,cgsj,fsmx_no from dxpt_fsmx where wczt='发送失败'");
            }
    放下电子产品,每天进步一点点
  • 相关阅读:
    redis相关问题
    redis的持久化功能
    redis运维常用的server端命令
    Redis运维时需要注意的参数
    redis模拟消息订阅
    redis设置密码
    redis简单的事务
    Redis的配置文件详解
    Linux中安装redis的phpredis扩展
    css动画属性--小球移动
  • 原文地址:https://www.cnblogs.com/vienna/p/3450688.html
Copyright © 2020-2023  润新知