第三方控件DevExpress使用大全开发过程中整理收集.docx

上传人:b****7 文档编号:10147997 上传时间:2023-02-08 格式:DOCX 页数:24 大小:631.40KB
下载 相关 举报
第三方控件DevExpress使用大全开发过程中整理收集.docx_第1页
第1页 / 共24页
第三方控件DevExpress使用大全开发过程中整理收集.docx_第2页
第2页 / 共24页
第三方控件DevExpress使用大全开发过程中整理收集.docx_第3页
第3页 / 共24页
第三方控件DevExpress使用大全开发过程中整理收集.docx_第4页
第4页 / 共24页
第三方控件DevExpress使用大全开发过程中整理收集.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

第三方控件DevExpress使用大全开发过程中整理收集.docx

《第三方控件DevExpress使用大全开发过程中整理收集.docx》由会员分享,可在线阅读,更多相关《第三方控件DevExpress使用大全开发过程中整理收集.docx(24页珍藏版)》请在冰豆网上搜索。

第三方控件DevExpress使用大全开发过程中整理收集.docx

第三方控件DevExpress使用大全开发过程中整理收集

第三方控件使用大全

【本人开发过程中整理】

一、ComboBoxEdit

1、如何使其不可编辑

TextEditStyle设置为:

DisableTextEditor

2、如何设置鼠标为手形

Cursor设置为:

Hand

二、GridControl

1、如何解决单击记录整行选中的问题

View->OptionsBehavior->EditorShowMode设置为:

Click

2、如何新增一条记录

(1)、gridView.AddNewRow()

(2)、实现gridView_InitNewRow事件

3、如何解决GridControl记录能获取而没有显示出来的问题

gridView.populateColumns();

4、如何让行只能选择而不能编辑(或编辑某一单元格)

(1)、View->OptionsBehavior->EditorShowMode设置为:

Click

(2)、View->OptionsBehavior->Editable设置为:

false

5、如何禁用GridControl中单击列弹出右键菜单

设置RunDesign->OptionsMenu->EnableColumnMenu设置为:

false

6、如何隐藏GridControl的GroupPanel表头

设置RunDesign->OptionsView->ShowGroupPanel设置为:

false

7、如何禁用GridControl中列头的过滤器

过滤器如下图所示:

设置RunDesign->OptionsCustomization->AllowFilter设置为:

false

8、如何在查询得到0条记录时显示自定义的字符提示/显示

如图所示:

方法如下:

//WhennoRecordsAreBeingDisplayed

privatevoidgridView1_CustomDrawEmptyForeground(objectsender,CustomDrawEventArgse)

{

//方法一(此方法为GridView设置了数据源绑定时,可用)

ColumnViewcolumnView=senderasColumnView;

BindingSourcebindingSource=this.gridView1.DataSourceasBindingSource;

if(bindingSource.Count==0)

{

stringstr="没有查询到你所想要的数据!

";

Fontf=newFont("宋体",10,FontStyle.Bold);

Rectangler=newRectangle(e.Bounds.Top+5,e.Bounds.Left+5,e.Bounds.Right-5,e.Bounds.Height-5);

e.Graphics.DrawString(str,f,Brushes.Black,r);

}

//方法二(此方法为GridView没有设置数据源绑定时,使用,一般使用此种方法)

if(this._flag)

{

if(this.gridView1.RowCount==0)

{

stringstr="没有查询到你所想要的数据!

";

Fontf=newFont("宋体",10,FontStyle.Bold);

Rectangler=newRectangle(e.Bounds.Left+5,e.Bounds.Top+5,e.Bounds.Width-5,e.Bounds.Height-5);

e.Graphics.DrawString(str,f,Brushes.Black,r);

}

}

}

9、如何显示水平滚动条?

设置this.gridView.OptionsView.ColumnAutoWidth=false;

10、如何定位到第一条数据/记录?

设置this.gridView.MoveFirst()

11、如何定位到下一条数据/记录?

设置this.gridView.MoveNext()

12、如何定位到最后一条数据/记录?

设置this.gridView.MoveLast()

13、设置成一次选择一行,并且不能被编辑

this.gridView1.FocusRectStyle=DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;

this.gridView1.OptionsBehavior.Editable=false;

this.gridView1.OptionsSelection.EnableAppearanceFocusedCell=false;

14、如何显示行号?

this.gridView1.IndicatorWidth=40;

//显示行的序号

privatevoidgridView1_CustomDrawRowIndicator(objectsender,RowIndicatorCustomDrawEventArgse)

{

if(e.Info.IsRowIndicator&&e.RowHandle>=0)

{

e.Info.DisplayText=(e.RowHandle+1).ToString();

}

}

15、如何让各列头禁止移动?

设置gridView1.OptionsCustomization.AllowColumnMoving=false;

16、如何让各列头禁止排序?

设置gridView1.OptionsCustomization.AllowSort=false;

17、如何禁止各列头改变列宽?

设置gridView1.OptionsCustomization.AllowColumnResizing=false;

18、

19、

20、

21、

22、

23、

24、

25、

26、

 

三、navBarControl

1、如何在每一个navBarGroup里添加自己想要的控件

设置GroupStyle:

ControlContainer

2、如何设置navBarGroup有滚动条

设置SkinExplorerBarViewScrollStyle:

ScrollBar

3、如休把navBarGroup设置成如下样式

如图所示:

设置navBarGroup的PaintStyleName属性为:

SkinNavigationPane

四、toolTipController

效果图如下:

1、如何设置显示的时间长短

设置this.toolTipController1.AutoPopDelay=2000;

2、如何在屏幕上显示如上图所示的效果

ToolTipControllerShowEventArgsargs=this.toolTipController1.CreateShowArgs();

this.toolTipController1.SetToolTip(this.sbtnYes,"请选择一条记录!

");

this.toolTipController1.SetTitle(this.sbtnYes,"提示");

this.toolTipController1.SetToolTipIconType(this.sbtnYes,DevExpress.Utils.ToolTipIconType.Exclamation);

this.toolTipController1.ShowBeak=true;

this.toolTipController1.ShowShadow=true;

this.toolTipController1.Rounded=true;

this.toolTipController1.ShowHint("请选择一条记录!

","提示");

args.ToolTip="请选择一条记录!

";

args.Title="提示";

3、如何设置边框的颜色

this.toolTipController1.Appearance.BorderColor=Color.Red;

五、TextEdit

1、如何设置TextEdit为多行,可拉伸

设置TextEdit的Propertity->AutoHeight为:

False

六、LayoutControl

1、如何设置LayoutItem为隐藏

设置LayoutItem.Visibility=Never

七、TreeList

1、如何隐藏TreeList的列头

设置TreeListr的OptionsView的ShowColumns属性为:

False

2、如何

八、PictureEdit

1、如何禁止PictureEdit的右键菜单?

设置PictureEdit的Properties->ShowMenu为:

false

九、TreeList

1、如何让TreeList的每个结点高亮显示?

效果如下:

代码如下:

privatevoidtreeList1_CustomDrawNodeCell(objectsender,DevExpress.XtraTreeList.CustomDrawNodeCellEventArgse)

{

TreeListnode=senderasTreeList;

if(e.Node==node.FocusedNode)

{

e.Graphics.FillRectangle(SystemBrushes.Window,e.Bounds);

Rectangler=newRectangle(e.EditViewInfo.ContentRect.Left,

e.EditViewInfo.ContentRect.Top,

Convert.ToInt32(e.Graphics.MeasureString(e.CellText,treeList1.Font).Width+1),

Convert.ToInt32(e.Graphics.MeasureString(e.CellText,treeList1.Font).Height));

e.Graphics.FillRectangle(SystemBrushes.Highlight,r);

e.Graphics.DrawString(e.CellText,treeList1.Font,SystemBrushes.HighlightText,r);

e.Handled=true;

}

}

//============================================================================

//===============================以下内容为收集===============================

//============================================================================

一、改变grid的样式。

DevExpress.XtraGrid.Design.XAppearancesxapp;

xapp=newDevExpress.XtraGrid.Design.XAppearances(System.Environment.GetFolderPath(System.Environment.SpecialFolder.System)+"\\DevExpress.XtraGrid.Appearances.xml");

xapp.LoadScheme(“样式名字”,gridControl1.MainView);

二、选择单元设置和取所选的值

gridView1.OptionsSelection.MultiSelect=ceMultiSelect.Checked;//多行选择

gridView1.OptionsSelection.MultiSelectMode=GridMultiSelectMode.CellSelect;

gridView1.OptionsSelection.MultiSelectMode=GridMultiSelectMode.RowSelect;//

三、gridview的控制

///<取当前选中的值>

stringGetSelectedRows(GridViewview){

stringret="";

introwIndex=-1;

if(view.OptionsSelection.MultiSelectMode==GridMultiSelectMode.RowSelect){

foreach(intiingridView1.GetSelectedRows()){

DataRowrow=gridView1.GetDataRow(i);

if(ret!

="")ret+="\r\n";

ret+=string.Format("CompanyName:

{0}(#{1})",row["CompanyName"],i);

}

}

else{

foreach(GridCellcellinview.GetSelectedCells()){

if(rowIndex!

=cell.RowHandle){

if(ret!

="")ret+="\r\n";

ret+=string.Format("Row:

#{0}",cell.RowHandle);

}

ret+="\r\n"+view.GetRowCellDisplayText(cell.RowHandle,cell.Column);

rowIndex=cell.RowHandle;

}

}

returnret;

}

 

///<设置选中的颜色>//半透明的效果

privatevoidicbTranslucentColors_CheckedChanged(objectsender,System.EventArgse){

if(icbTranslucentColors.Checked){

gridView1.Appearance.SelectedRow.BackColor=Color.FromArgb(30,0,0,240);

gridView1.Appearance.FocusedRow.BackColor=Color.FromArgb(60,0,0,240);

}

else{

gridView1.Appearance.SelectedRow.Reset();

gridView1.Appearance.FocusedRow.Reset();

}

}

///<自动添加一行>

gridView1.OptionsView.NewItemRowPosition=NewItemRowPosition.Bottom//Top/None;

///<设置gridView的按钮>

gridView1.ShowButtonMode=ShowButtonModeEnum.。

gridView1.OptionsBehavior.Editable=chEdit.Checked;//设置按钮是否可用

///向选中的空间输入字符串

SendKeys.Send(“fsfds”);

///控件焦点

gridControl1.Focus();

 

四、cardView的设置

///是否现实快捷按钮CustomizeButton

cardView1.OptionsView.ShowQuickCustomizeButton=true/false;

///设置CustomizeButton的能否排序和过滤

foreach(GridColumncolincardView1.Columns)

{col.OptionsColumn.AllowSort}

foreach(GridColumncolincardView1.Columns)

{col.OptionsFilter.AllowFilter}

///card的头上的ico显示

cardView1.LayoutChanged();

///card的头上的标题改变显示

cardView1.CardCaptionFormat=””;

///cardview显示的单个记录的折叠按钮

cardView1.OptionsView.ShowCardExpandButton=true;

///

cardView1.MaximumCardColumns=iSize

cardView1.MaximumCardRows=val;

cardView1.OptionsBehavior.AutoHorzWidth

///多选

cardView1.OptionsSelection.MultiSelect=ceMultiSelect.Checked;

foreach(intiincardView1.GetSelectedRows()){

DataRowrow=cardView1.GetDataRow(i);

if(ret!

="")ret+="\r\n";

ret+=string.Format("{0}/{1}:

{2:

$#,0.00}",row["Trademark"],row["Model"],row["Price"]);

}///查看选择中的记录

CellMerging(单元格合并的效果)

///

CellMerging(单元格合并的效果)

gridView1.OptionsView.AllowCellMerge=ceMerging.Checked;

FixedBands(bandedGridView)

///两边固定

gridBand3的一列的Fixed属性改成Right,Left,None

///固定与非固定列之间的距离用

bandedGridView2.FixedLineWidth=(int)numFixedLineWidth.Value;

///设置列的颜色

●打开RunDesigner选中Columns选中要改变的列里面有AppearanceCell(设置列的外观)和AppearanceHeader(设置表格头的外观)

●或者选中该列查看“属性”里面也有这两个属性。

///统计(gridViewbandedGridView通用)

分组统计和全部统计:

全部统计:

在最下面显示统计的结果。

RunDesigner->TotalSummary//->General设置显示

//->Columns对特定列来设置统计

汇总结果是否显示:

可以通过gridControl的view的ShowFooter属性来设置表格下面的汇总结果

分组统计:

以上就是“分组”的显示在每个分组下面来显示汇总结果。

通过bandedGridView2.GroupFooterShowMode=GroupFooterShowMode.。

设置分组的显示模式。

///GridView设置菜单

#regionGridevents

privatevoidgridView1_ShowGridMenu(objectsender,DevExpress.XtraGrid.Views.Grid.GridMenuEventArgse){

if(e.MenuType==DevExpress.XtraGrid.Views.Grid.GridMenuType.Column){

DevExpress.XtraGrid.Menu.GridViewColumnMenumenu=e.MenuasDevExpress.XtraGrid.Menu.GridViewColumnMenu;

menu.Items.Clear();

if(menu.Column!

=null){

menu.Items.Add(CreateCheckItem("NotFixed",menu.Column,FixedStyle.None,imageList2.Images[0]));

menu.Items.Add(CreateCheckItem("FixedLeft",menu.Column,FixedStyle.Left,imageList2.Images[1]));

menu.Items.Add(CreateCheckItem("FixedRight",menu.Column,FixedStyle.Right,imageList2.Images[2]));

}

}

}

#endregion

#regionNewcolumnmenu

DXMenuCheckItemCreateCheckItem(stringcaption,GridColumncolumn,FixedStylestyle,Imageimage){

DXMenuCheckItemitem=newDXMenuCheckItem(caption,column.Fixed==style,image,newEventHandler(OnFixedClick));

item.Tag=newMenuInfo(column,style);

returnitem;

}

voidOnFixedClick(objectsender,EventArgse){

DXMenuItemitem=senderasDXMenuItem;

MenuInfoinfo=item.TagasMenuInfo;

if(info==null)return;

info.Column.Fixed=info.Style;

}

classMenuInfo{

publicMenuInfo(GridColumncolumn,FixedStylestyle){

this.Column=column;

this.Style=style;

}

publicFixedStyle

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 预防医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1