随笔-7  评论-24  文章-102  trackbacks-0

DataGridView
DataGridView上按右键弹出右键菜单前选中当前行
        private void DataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        
{
            DataGridView1.ClearSelection();
            DataGridView1.Rows[e.RowIndex].Selected 
= true;
            DataGridView1.CurrentCell 
= DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
        }


/*
2007-05-16 17:31 by HELLO [未注册用户] 
用“dataGridView1_CellMouseClick”这个事件 

有些时候可以只弹出菜单,没有选择单元格;有时候只选择单元格,没有弹出菜单 

如果菜单控件在绑在DATAGRIDVIEW上(dataGridView1.ContextMenuStrip = this.ContextSrtip1),又不能选择单元格
*/

DataGridView 超链接点击事件
        //内容点击, 并判断所点击的列名
        private void dgvData_CellContentClick(object sender, DataGridViewCellEventArgs e)
        
{
            DataGridView dgv 
= sender as DataGridView;
            
string columnName = dgv.Columns[e.ColumnIndex].Name;
            
if ("operation".Equals(columnName))
            
{//如果点击的列名符合                
                dgv.Rows.RemoveAt(e.RowIndex);
            }

        }



TreeView
c# winform TreeView控件中实现拖拽的功能

节点拖拽事件

posted on 2009-07-10 12:21 黄小二 阅读(608) 评论(0)  编辑  收藏 所属分类: C#

只有注册用户登录后才能发表评论。


网站导航: