DevExpress使用技巧Word格式文档下载.docx
《DevExpress使用技巧Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《DevExpress使用技巧Word格式文档下载.docx(24页珍藏版)》请在冰豆网上搜索。
barSubItem.AddItem(barButtonItem);
4.奇怪的删除Page问题
while(this.ribbonControl.Pages.Count>
0){
ribbonControl.Pages.Remove(ribbonControl.Pages[0]);
//调试正常,运行报异常
}
ribbonControl.SelectedPage=ribbonControl.Pages[0];
ribbonControl.Pages.Remove(ribbonControl.SelectedPage);
//运行正常
5.RIBBON问题汇集
//禁止F10键Tips
ribbonControl.Manager.UseF10KeyForMenu=false;
//DX按钮
ApplicationIcon属性改变图标
右键AddApplicationMenu添加evExpress.XtraBars.Ribbon.ApplicationMenu5.HitInfo//在Tab页上点击右键的事件响应
voidxtraTabbedMdiManager_Event(objectsender,MouseEventArgse){
if(e.Button==MouseButtons.Right&
ActiveMdiChild!
=null)
{
DevExpress.XtraTab.ViewInfo.BaseTabHitInfohInfo=xtraTabbedMdiManager.CalcHitInfo(e.Location);
//右键点击位置:
在Page上且不在关闭按钮内
if(hInfo.IsValid&
hInfo.Page!
=null&
&
!
hInfo.InPageCloseButton)
this.popupMenu.ShowPopup(Control.MousePosition);
//在鼠标位置弹出,而不是
e.Location
//在ribbon上点击右键的事件响应
privatevoidribbonControl1_ShowCustomizationMenu(objectsender,RibbonCustomizationMenuEventArgse)
//禁掉原系统右键菜单
e.ShowCustomizationMenu=false;
//右键位置:
在barButtonItem上
if(e.HitInfo!
=null
e.HitInfo.InItem
e.HitInfo.Item.ItemisBarButtonItem)
在barSubItem中的barButtonItem上
elseif(e.Link!
e.Link.Item!
e.Link.ItemisBarButtonItem)
6.皮肤
//添加皮肤程序集后注册皮肤
DevExpress.UserSkins.OfficeSkins.Register();
DevExpress.UserSkins.BonusSkins.Register();
//设置皮肤
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("
LiquidSky"
);
//若皮肤名
称错误则按系统默认设置(第一个皮肤)
//GalleryFilterMenuPopup事件设置弹出筛选菜单的“AllGroups”为中文
privatevoidrgbiSkins_GalleryFilterMenuPopup(objectsender,GalleryFilterMenuEventArgse)
e.FilterMenu.ItemLinks[n].Caption="
所有皮肤"
//n=分组数+1
//GalleryInitDropDownGallery事件设置弹出皮肤列表的表头“ALLGroups”为中文
privatevoidrgbiSkins_GalleryInitDropDownGallery(objectsender,InplaceGalleryEventArgse)
e.PopupGallery.FilterCaption="
7.dockManager
将视图的状态信息保存到xml文件
dockManager1.SaveLayoutToXml("
..\\UserConfig\\ViewInfo.xml"
导出xml中保存的状态信息
dockManager1.RestoreLayoutFromXml("
8.barManager设置bar的字体与系统字体
barAndDockingController1.AppearancesBar.ItemsFont=newFont(this.Font.FontFamily,currentFontSize);
9.设置系统字体
DevExpress.Utils.AppearanceObject.DefaultFont=newFont(this.Font.FontFamily,currentFontSize);
10.treeView
为tree节点加右键菜单并选中该节点
privatevoidtreeList1_MouseDown(objectsender,MouseEventArgse)
if(e.Button==MouseButtons.Right)
DevExpress.XtraTreeList.TreeListHitInfohi=treeList1.CalcHitInfo(e.Location);
if(hi.Node!
hi.Node.ImageIndex==5)//叶子节点的ImageIndex==5
TreeListNodenode=treeList1.FindNodeByID(hi.Node.Id);
treeList1.FocusedNode=node;
this.popupMenu1.ShowPopup(MousePosition);
二、DevExpress部分使用技巧(原创)作者:
轻舞肥羊
标题:
DevExpress部分使用技巧(原创)
关键字:
DevExpress,cxGrid
分类:
开发技巧
密级:
公开
(评分:
?
回复:
7,阅读:
8588)&
raquo;
本文由轻舞肥羊发表于大富翁论坛
转载请标明出处,谢谢
声明:
以下代码请看懂再使用,本人水平有限,发现bug希望提出,让我们共同改进
2004-1-1017:
06:
00
查看评语&
1.扩展cxLookupComboBox,使其支持多列查询的cxLookupComboBoxEx
日期:
08:
06
//=====================================================================
=========
//UnitName:
cxLookupComboBoxEx//Author:
ysai
//Date:
2003
//Purpose:
扩展cxLookupComboBox,cxDBLookupComboBox,使其支持多列过滤//History:
//2003-05-28大数据量改进
//2003-07-07可操作性改进
//2003-08-20效率改进
//2003-08-29加入过滤延时
//注意:
//限制1,不能再使用Properties.OnChange事件
//限制2,不能再使用Properties.ListSource.DataSet.OnFilterRecord事件//限制3,不能再使用Properties.ListSource.DataSet.Filtered属性//其它,最好在设计期设好一切属性,运行期再设置属性可能引发求知错误//=====================================================================
unitcxLookupComboBoxEx;
interface
uses
SysUtils,Classes,Controls,Windows,Messages,DB,StrUtils,
cxControls,cxContainer,cxEdit,cxTextEdit,
cxMaskEdit,cxDropDownEdit,cxLookupEdit,cxDBLookupEdit,
cxDBLookupComboBox;
type
TcxLookupComboBoxEx=class(TcxLookupComboBox)
private
//保存要过滤的字段列表
FFieldList:
TList;
FFindText:
String;
//过滤事件
procedure_OnFilterRecord(DataSet:
TDataSet;
varAccept:
Boolean);
//编辑框文字改变事件
procedure_OnChange(Sender:
TObject);
procedureGetFieldList;
//延时过滤消息
procedureWMTimer(varMessage:
TMessage);
messageWM_TIMER;
protected
//下拉表格收回时
procedureCloseUp(AAccept:
override;
//过滤过程
procedure_FilterListSource;
//初始化下拉表格事件
procedureDoInitPopup;
public
constructorCreate(AOwner:
TComponent);
destructorDestroy;
//更新要过滤的字段列表
procedureUpdateFilterFields;
published
end;
TcxDBLookupComboBoxEx=class(TcxDBLookupComboBox)
//取得要过滤的字段列表
procedureRegister;
implementation
const
UM_TIMER_FILTER=WM_USER+$101;
//自定义延时消息ID
FILTERTIMER=500;
//延时时间
DROPDOWN_ROWS=12;
begin
RegisterComponents('
DevExpress'
[TcxLookupComboBoxEx,TcxDBLookupComboBoxEx]);
{TcxLookupComboBoxEx}
procedureTcxLookupComboBoxEx.CloseUp(AAccept:
inherited;
//收起下拉后取消过滤
ifAssigned(Properties.ListSource)then
ifAssigned(Properties.ListSource.DataSet)then
Properties.ListSource.DataSet.Filtered:
=False;
end;
constructorTcxLookupComboBoxEx.Create(AOwner:
begin
//默认值
Properties.AutoSelect:
Properties.DropDownAutoSize:
=True;
Properties.DropDownListStyle:
=lsEditList;
Properties.DropDownRows:
=DROPDOWN_ROWS;
Properties.DropDownSizeable:
Properties.IncrementalFiltering:
Properties.Revertable:
Properties.OnChange:
=_OnChange;
Properties.UseLeftAlignmentOnEditing:
destructorTcxLookupComboBoxEx.Destroy;
//释放过滤字段列表
ifAssigned(FFieldList)thenFFieldList.Free;
procedureTcxLookupComboBoxEx.DoInitPopup;
//取得过滤字段
GetFieldList;
inheritedDoInitPopup;
procedureTcxLookupComboBoxEx._FilterListSource;
//过滤字段
ifAssigned(Properties.ListSource)
andAssigned(Properties.ListSource.DataSet)then
try
Properties.ListSource.DataSet.DisableControls;
Properties.ListSource.DataSet.OnFilterRecord:
=_OnFilterRecord;
ifText<
>
'
'
then
=Text;
ifSelLength>
0then
=LeftStr(Text,SelStart);
=FFindText<
Changed;
finally
Properties.ListSource.DataSet.EnableControls;
procedureTcxLookupComboBoxEx.GetFieldList;
//取得过滤字段列表
var
i:
Integer;
sFieldName:
fdTemp:
TField;
ifnotAssigned(FFieldList)then
=TList.Create;
fori:
=0toProperties.ListColumns.Count-1do
=Properties.ListColumns.Items[i].FieldName;
ifsFieldName='
thenContinue;
=Properties.ListSource.DataSet.FindField(sFieldName);
ifAssigned(fdTemp)then
FFieldList.Add(Pointer(fdTemp));
procedureTcxLookupComboBoxEx._OnChange(Sender:
//设置延时
ifFocusedandDroppedDownthen
KillTimer(Handle,UM_TIMER_FILTER);
SetTimer(Handle,UM_TIMER_FILTER,FILTERTIMER,nil);
procedureTcxLookupComboBoxEx._OnFilterRecord(DataSet:
varAccept:
s:
=LowerCase(FFindText);
if(s<
)and(Properties.ListColumns.Count>
0)then
Accept:
fori:
=0toFFieldList.Count-1do
=Pos(s,LowerCase(TField(FFieldList[i]).AsString))>
0;
ifAcceptthenExit;
end
else
procedureTcxLookupComboBoxEx.WMTimer(varMessage:
//延时更新消息
ifFocusedandDroppedDownthen_FilterListSource;
procedureTcxLookupComboBoxE