• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

delphiribbon使用

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

http://blog.csdn.net/davinciyxw/article/details/5604209

 

1.TextEditor(barEditItem)取文本

string editValue = barEditItem1.EditValue.ToString(); //错误,返回null

string editValue = ((DevExpress.XtraEditors.TextEdit)barEditItem).EditValue.ToString(); //正确,返回文本框内容

2.ComboBoxEdit(barEditItem)添加Item

string item = "comboboxItem1";
((DevExpress.XtraEditors.Repository.RepositoryItemComboBox)this.barEditItem.Edit).Items.Add(item);

3.ComboBoxEdit(barEditItem)取文本

string itemValue = this.barEditItem.EditValue.ToString();

4.Ribbon控件

//添加Page
DevExpress.XtraBars.Ribbon.RibbonPage ribbonPage = new RibbonPage();
ribbonControl.Pages.Add(ribbonPage);
//添加Group
DevExpress.XtraBars.Ribbon.RibbonPageGroup ribbonPageGroup = new RibbonPageGroup();
ribbonPage.Groups.Add(ribbonPageGroup);
//添加Button
DevExpress.XtraBars.BarButtonItem barButtonItem = new BarButtonItem();
ribbonPageGroup.ItemLinks.Add(barButtonItem);
//添加barSubItem
DevExpress.XtraBars.BarSubItem barSubItem = new BarSubItem();
ribbonPageGroup.ItemLinks.Add(barSubItem);
//barSubItem下添加Button
barSubItem.AddItem(barButtonItem);


//奇怪的删除Page问题
while (this.ribbonControl.Pages.Count > 0)
{
ribbonControl.Pages.Remove(ribbonControl.Pages[0]); //调试正常,运行报异常
}
while (this.ribbonControl.Pages.Count > 0)
{
ribbonControl.SelectedPage = ribbonControl.Pages[0];
ribbonControl.Pages.Remove(ribbonControl.SelectedPage); //运行正常
}
//禁止F10键Tips
ribbonControl.Manager.UseF10KeyForMenu = false;
//DX按钮
ApplicationIcon属性改变图标
右键 Add ApplicationMenu 添加evExpress.XtraBars.Ribbon.ApplicationMenu

5.HitInfo

//在Tab页上点击右键的事件响应
void xtraTabbedMdiManager_Event(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right && ActiveMdiChild != null)
{
DevExpress.XtraTab.ViewInfo.BaseTabHitInfo hInfo = xtraTabbedMdiManager.CalcHitInfo(e.Location);
//右键点击位置:在Page上且不在关闭按钮内
if (hInfo.IsValid && hInfo.Page != null && !hInfo.InPageCloseButton)
{
this.popupMenu.ShowPopup(Control.MousePosition);//在鼠标位置弹出,而不是e.Location
}
}
}
//在ribbon上点击右键的事件响应
private void ribbonControl1_ShowCustomizationMenu(object sender, RibbonCustomizationMenuEventArgs e)
{
//禁掉原系统右键菜单
e.ShowCustomizationMenu = false;
//右键位置:在barButtonItem上
if (e.HitInfo != null
&& e.HitInfo.InItem
&& e.HitInfo.Item.Item is BarButtonItem)
{
this.popupMenu.ShowPopup(Control.MousePosition);
}
//右键位置:在barSubItem中的barButtonItem上
else if (e.Link != null
&& e.Link.Item != null
&& e.Link.Item is BarButtonItem)
{
this.popupMenu.ShowPopup(Control.MousePosition);
}
}

6.皮肤

//添加皮肤程序集后注册皮肤
DevExpress.UserSkins.OfficeSkins.Register();
DevExpress.UserSkins.BonusSkins.Register();
//设置皮肤
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Liquid Sky"); //若皮肤名称错误则按系统默认设置(第一个皮肤)
//GalleryFilterMenuPopup事件设置弹出筛选菜单的“All Groups”为中文
private void rgbiSkins_GalleryFilterMenuPopup(object sender, GalleryFilterMenuEventArgs e)
{
e.FilterMenu.ItemLinks[n].Caption = "所有皮肤"; //n=分组数+1
}
//GalleryInitDropDownGallery事件设置弹出皮肤列表的表头“ALL Groups”为中文
private void rgbiSkins_GalleryInitDropDownGallery(object sender, InplaceGalleryEventArgs e)
{
e.PopupGallery.FilterCaption = "所有皮肤";
}

7.dockManager

将视图的状态信息保存到xml文件
dockManager1.SaveLayoutToXml("..//UserConfig//ViewInfo.xml");
导出xml中保存的状态信息
dockManager1.RestoreLayoutFromXml("..//UserConfig//ViewInfo.xml");

8.barManager

设置bar的字体与系统字体
barAndDockingController1.AppearancesBar.ItemsFont = new Font(this.Font.FontFamily, currentFontSize);

9.设置系统字体

DevExpress.Utils.AppearanceObject.DefaultFont = new Font(this.Font.FontFamily, currentFontSize);

10.treeView

为tree节点加右键菜单并选中该节点
private void treeList1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
DevExpress.XtraTreeList.TreeListHitInfo hi = treeList1.CalcHitInfo(e.Location);
if (hi.Node != null && hi.Node.ImageIndex == 5) //叶子节点的ImageIndex == 5
{
TreeListNode node = treeList1.FindNodeByID(hi.Node.Id);
treeList1.FocusedNode = node;

this.popupMenu1.ShowPopup(MousePosition);
}
}
}


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap