예제 #1
0
        private void dgv_output_IsTruly_BeforeCellPaint(object sender, BeforeCellPaintEventArgs e)
        {
            DataGridViewCheckBoxXColumn sc =
                sender as DataGridViewCheckBoxXColumn;

            if (sc != null)
            {
                switch (sc.CheckState)
                {
                case CheckState.Checked:
                    sc.Text      = "匹配";
                    sc.TextColor = Color.Green;
                    break;

                case CheckState.Unchecked:
                    sc.Text      = "不匹配";
                    sc.TextColor = Color.Red;
                    break;

                default:
                    sc.Text      = "难说";
                    sc.TextColor = Color.DarkGray;
                    break;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Handles X2 "Feedback" BeforeCellPaint events
        /// </summary>
        /// <param name="sender">DataGridViewCheckBoxXColumn</param>
        /// <param name="e">BeforeCellPaintEventArgs</param>
        void X2Feedback_BeforeCellPaint(object sender, BeforeCellPaintEventArgs e)
        {
            DataGridViewCheckBoxXColumn sc =
                sender as DataGridViewCheckBoxXColumn;

            if (sc != null)
            {
                switch (sc.CheckState)
                {
                case CheckState.Checked:
                    sc.Text      = "Positive";
                    sc.TextColor = Color.Green;
                    break;

                case CheckState.Unchecked:
                    sc.Text      = "Negative";
                    sc.TextColor = Color.Red;
                    break;

                default:
                    sc.Text      = "----";
                    sc.TextColor = Color.DarkGray;
                    break;
                }
            }
        }
예제 #3
0
        private void WeiboForm_Load(object sender, EventArgs e)
        {
            DataGridViewCheckBoxXColumn cb =
                dgv_output.Columns["IsTruly"] as DataGridViewCheckBoxXColumn;

            if (cb != null)
            {
                cb.BeforeCellPaint += dgv_output_IsTruly_BeforeCellPaint;
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes our X2 "Feedback" environment
        /// </summary>
        private void X2Feedback_Initialize()
        {
            DataGridViewCheckBoxXColumn cb =
                dataGridViewX2.Columns["Feedback"] as DataGridViewCheckBoxXColumn;

            // Hook onto the BeforeCellPaint event so we can
            // demonstrate cell customization

            if (cb != null)
            {
                cb.BeforeCellPaint += X2Feedback_BeforeCellPaint;
            }
        }
예제 #5
0
        /// <summary>
        /// 创建DataGridView扩展的CheckBox列
        /// </summary>
        /// <param name="_dgv">要创建列的DataGridView</param>
        /// <param name="_alignment">设置列的对齐方式</param>
        /// <param name="_columnName">列名</param>
        /// <param name="_headerText">标题名</param>
        /// <param name="_dataPropertyName">绑定数据源的字段名称</param>
        /// <param name="_toolTipText">TipText提示</param>
        /// <param name="_readOnly">设置列是否只读,true 只读,false 读写</param>
        /// <param name="_visible">设置列是否可见,true 显示,false 隐藏</param>
        /// <param name="_notEmpty">设置列是否为必填列,true 必填,false 非必填</param>
        /// <param name="_backColor">设置列的背景色,当_notEmpty为true时,此项为必需值,为false,此项可以为Color.Empty</param>
        /// <param name="_columnState">装载DataGridView可写可读、只读列的数据字典</param>
        public static void InitDgvCheckBoxXColumn(DataGridView _dgv,
                                                  DataGridViewContentAlignment _alignment, string _columnName, string _headerText,
                                                  string _dataPropertyName, string _toolTipText, bool _readOnly, bool _visible, bool _notEmpty,
                                                  Color _backColor, ref Dictionary <string, bool> _columnState)
        {
            DataGridViewCheckBoxXColumn checkBoxXCol = new DataGridViewCheckBoxXColumn();

            checkBoxXCol.HeaderCell.Style.Alignment = _alignment == 0 ? DataGridViewContentAlignment.MiddleLeft : _alignment;
            checkBoxXCol.Name             = _columnName;
            checkBoxXCol.HeaderText       = _headerText;
            checkBoxXCol.DataPropertyName = _dataPropertyName;
            checkBoxXCol.ToolTipText      = _toolTipText;
            checkBoxXCol.Visible          = _visible;
            checkBoxXCol.ReadOnly         = _readOnly;
            if (_notEmpty == true)
            {
                checkBoxXCol.DefaultCellStyle.BackColor = _backColor;
            }
            _columnState.Add(_columnName, _readOnly);
            _dgv.Columns.Add(checkBoxXCol);
        }