【终结:devexpress】相关控件零星记录

1,gridcontrol添加checkbox列编辑点三下的问题?

解决方法:不要设置这个属性,让它默认。我的控件属性通常是用代码设置,注释掉就ok了。

//gridView1.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click;

2,Gridcontrol右键菜单

DevExpress中GridView上的右键菜单

image

如上图,先选中GridView,不是GridControl,在属性窗口中,选择事件窗口,注册事件MouseUp  
代码如下,其中popupMenu_ResumeGrid为DevExpress.XtraBars.PopupMenu

gridView_ResumeCollection为private DevExpress.XtraGrid.Views.Grid.GridView

----------------------------------------------------------------

private void gridView_ResumeCollection_MouseUp(object sender, MouseEventArgs e) {  
            DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi =this.gridView_ResumeCollection.CalcHitInfo(e.Location);   
            if (hi.InRow && e.Button == MouseButtons.Right) {   
                popupMenu_ResumeGrid.ShowPopup(Control.MousePosition);   
            }   
        }

----------------------------------------------------------------

备注序列化和反序列化代码

IFormatter formatter = new BinaryFormatter();  
                using (Stream stream = new FileStream(ResumeCollection.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read)) {   
                    if (stream.Length > 0) {   
                        formatter.Serialize(stream, new object());   
                        //ResumeCollection = (ResumeCollection)formatter.Deserialize(stream);   
                        stream.Close();   
                    }   
                }

DevExpress 给TreeList添加右键菜单

只有在右击节点时才会触发

private void treeList1_MouseDown(object sender, MouseEventArgs e)
{

if (e.Button == MouseButtons.Right)
{
treeList1.ContextMenuStrip = null;

TreeListHitInfo hInfo = treeList1.CalcHitInfo(new Point(e.X, e.Y));
TreeListNode node = hInfo.Node;
treeList1.FocusedNode = node;
if (node!=null)
{
treeList1.ContextMenuStrip = contextMenuStrip1;
}
}

}

添加BarManager和popupMenu组建:

设置popupMenu组件的Manager属性:

右键点击popupMenu主键,点击Customize选项添加菜单:




然后便可添加到鼠标事件中,此处以TreeList为例:

        private void treeList1_MouseUp(object sender, MouseEventArgs e)
        {
            TreeList tree = sender as TreeList;
            if (e.Button == MouseButtons.Right
                    && ModifierKeys == Keys.None
                    && treeList1.State == TreeListState.Regular)
            {
                Point p = new Point(Cursor.Position.X, Cursor.Position.Y);
                TreeListHitInfo hitInfo = tree.CalcHitInfo(e.Location);
                if (hitInfo.HitInfoType == HitInfoType.Cell)
                {
                    tree.SetFocusedNode(hitInfo.Node);
                }

                if (tree.FocusedNode != null)
                {
                    popupMenu1.ShowPopup(p);
                }
            }
        }

 

分别转自: http://www.cnblogs.com/kkun/archive/2010/01/14/1647570.html
                  http://jlcon.iteye.com/blog/899840#
 
补充一点,那个工具条和状态栏在customize里面都可以勾掉,最后显示的时候,顶部还有个空白工具条,干掉方法:设置bar的visible为false(属性面板)。今天发现也可以直接把那个bar2给删了。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值