DataGridView中添加了右鍵菜單(C#) 多行選中 添加事件

1.  添加ContextMenuStrip快捷菜單控件this

2.  添加ContextMenuStrip事件orm

3. DataGridView 右鍵屬性關聯ContextMenuStrip事件

bool isChecked = true;ip

if (this.dataGridView1.Rows != null)
            {
                for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Selected == true) //該行是否選中
                    {
                        this.dataGridView1.Rows[i].Cells[0].Value = isChecked; //勾選改行復選框
                    }
                }
                this.dataGridView1.RefreshEdit();
            }it

添加事件di

            this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
            this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
            this.dataGridView1.CellContentDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentDoubleClick);
 data

相關文章
相關標籤/搜索