DonkingControlBase/LookupEditor/BxDataGridView.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/*
 * Author donking
 * http://www.donking-ch.com/ 
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace DonkingControlBase
{
    /// <summary>
    /// 重写列头和行头样式GridView
    /// </summary>
    public partial class BxDataGridView : DataGridView
    {
        /// <summary>
        /// 弹出右键菜单
        /// </summary>
        public delegate void ShowContextMenu(object sender);
        public event ShowContextMenu ShowContextMenuEvent;//右键事件   

        /// <summary>
        /// 构造函数
        /// </summary>
        public BxDataGridView()
        {
            InitializeComponent();
            this.CellMouseClick += new DataGridViewCellMouseEventHandler(DataGridView_CellMouseDown);
        }

        /// <summary>
        /// 右键事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
                {
                    DataGridView dgv = sender as DataGridView;
                    //若行已是选中状态就不再进行设置
                    if (dgv.Rows[e.RowIndex].Selected == false)
                    {   
                        dgv.ClearSelection();
                        dgv.Rows[e.RowIndex].Selected = true;
                    }
                    //只选中一行时设置活动单元格                    
                    if (dgv.SelectedRows.Count == 1)
                        dgv.CurrentCell = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];

                    //进行相应的操作                    
                    if (ShowContextMenuEvent != null)
                        ShowContextMenuEvent(sender);
后面还有 40 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。