예제 #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }
            if (e.ColumnIndex == 2)
            {
                DataGridViewDisableButtonCell button = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewDisableButtonCell;
                if (button.Enabled == false)
                {
                    return;
                }
            }

            if (e.ColumnIndex == 2)
            {
                //可以在此打开新窗口,把参数传递过去
                //MessageBox.Show(this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                string strRemark = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                string strDate   = this.dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                strDate = DateTime.Parse(strDate).ToString("yyyy-MM-dd");
                string insertSql = string.Format("insert into MessageHandle (Remark,HandleDate) values ('{0}','{1}')",
                                                 strRemark, strDate);

                SqliteDBUtility.DbHelperSQLite.ExecuteSql(insertSql);
                DataGridViewDisableButtonCell button = dataGridView1.Rows[e.RowIndex].Cells[2] as DataGridViewDisableButtonCell;
                if (button != null)
                {
                    button.Enabled = false;
                }
                dataGridView1.Invalidate();
            }
        }
예제 #2
0
        // Override the Clone method so that the Enabled property is copied.
        public override object Clone()
        {
            DataGridViewDisableButtonCell cell =
                (DataGridViewDisableButtonCell)base.Clone();

            cell.Enabled = this.Enabled;
            return(cell);
        }
예제 #3
0
        private void FrmMessage_Load(object sender, EventArgs e)
        {
            //DataTable dt = CommonFunction.GetDateRemarkDt(DateTime.Today);
            //dataGridView1.DataSource =
            foreach (DataRow dr in Dt.Rows)
            {
                DateTime dateTime = (DateTime)dr[1];

                string remark     = dr[0].ToString();
                string handleDate = dateTime.ToString("yyyy-MM-dd");


                int index = dataGridView1.Rows.Add(remark, handleDate, "已处理");



                //dataGridView1.Rows[index].Cells["Column2"].ReadOnly = true;
                //dataGridView1["Column2", index].ReadOnly = true;
                string    checkIshandle = string.Format("select * from MessageHandle where Remark='{0}' and HandleDate='{1}'", remark, handleDate);
                DataTable dt            = SqliteDBUtility.DbHelperSQLite.Query(checkIshandle).Tables[0];

                if (dt != null && dt.Rows.Count > 0)
                {
                    DataGridViewDisableButtonCell button = dataGridView1.Rows[index].Cells[2] as DataGridViewDisableButtonCell;
                    if (button != null)
                    {
                        button.Enabled = false;
                    }
                }
                //button.Enabled = false;


                //button.
            }
            dataGridView1.Invalidate();

            //txtRemark.Text = CommonFunction.GetDateRemark(DateTime.Today);
            //txtRemark.Select(txtRemark.TextLength, 0);//光标定位到文本最后
            //txtRemark.ScrollToCaret();//滚动到光标处s
        }