




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第三方控件使用大全【张杰章开发过程中整理】一、 ComboBoxEdit1、 如何使其不可编辑TextEditStyle 设置为:DisableTextEditor2、 如何设置鼠标为手形Cursor 设置为:Hand二、 GridControl1、 如何解决单击记录整行选中的问题View-OptionsBehavior-EditorShowMode 设置为:Click2、 如何新增一条记录(1)、gridView.AddNewRow()(2)、实现gridView_InitNewRow事件3、如何解决GridControl记录能获取而没有显示出来的问题 gridView.populateColumns();4、如何让行只能选择而不能编辑(或编辑某一单元格) (1)、View-OptionsBehavior-EditorShowMode 设置为:Click (2)、View-OptionsBehavior-Editable 设置为:false5、如何禁用GridControl中单击列弹出右键菜单 设置Run Design-OptionsMenu-EnableColumnMenu 设置为:false6、如何隐藏GridControl的GroupPanel表头 设置Run Design-OptionsView-ShowGroupPanel 设置为:false7、如何禁用GridControl中列头的过滤器 过滤器如下图所示: 设置 Run Design-OptionsCustomization-AllowFilter 设置为:false8、如何在查询得到0条记录时显示自定义的字符提示/显示 如图所示: 方法如下: /When no Records Are Being Displayed private void gridView1_CustomDrawEmptyForeground(object sender, CustomDrawEventArgs e) /方法一(此方法为GridView设置了数据源绑定时,可用) ColumnView columnView = sender as ColumnView; BindingSource bindingSource = this.gridView1.DataSource as BindingSource; if(bindingSource.Count = 0) string str = 没有查询到你所想要的数据!; Font f = new Font(宋体, 10, FontStyle.Bold); Rectangle r = new Rectangle(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) string str = 没有查询到你所想要的数据!; Font f = new Font(宋体, 10, FontStyle.Bold); Rectangle r = new Rectangle(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; /显示行的序号 private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e) 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、设置Gridview控件整体不可编辑 this.gridData.IsEnableEdit = false;19、5、判断Gridview当前索引int index=this.gridData.gridView1.GetFocusedDataSourceRowIndex() ;20、21、22、23、24、25、26、三、navBarControl1、如何在每一个navBarGroup里添加自己想要的控件 设置GroupStyle: ControlContainer2、如何设置navBarGroup有滚动条 设置SkinExplorerBarViewScrollStyle:ScrollBar3、 如休把navBarGroup设置成如下样式如图所示: 设置navBarGroup的PaintStyleName属性为: SkinNavigationPane四、toolTipController效果图如下:1、如何设置显示的时间长短 设置this.toolTipController1.AutoPopDelay = 2000;2、如何在屏幕上显示如上图所示的效果 ToolTipControllerShowEventArgs args = 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;五、TextEdit1、如何设置TextEdit为多行,可拉伸 设置TextEdit的Propertity-AutoHeight为:False六、LayoutControl 1、如何设置LayoutItem为隐藏 设置LayoutItem.Visibility = Never 七、TreeList1、如何隐藏TreeList的列头 设置TreeListr的OptionsView的ShowColumns属性为:False2、如何 八、PictureEdit1、如何禁止PictureEdit的右键菜单?设置PictureEdit的Properties-ShowMenu为:false九、TreeList1、 如何让TreeList的每个结点高亮显示?效果如下:代码如下:private void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e) TreeList node = sender as TreeList; if (e.Node = node.FocusedNode) e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds); Rectangle r = new Rectangle(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.XAppearances xapp;xapp=new DevExpress.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的控制/ string GetSelectedRows(GridView view) string ret = ; int rowIndex = -1; if(view.OptionsSelection.MultiSelectMode = GridMultiSelectMode.RowSelect) foreach(int i in gridView1.GetSelectedRows() DataRow row = gridView1.GetDataRow(i); if(ret != ) ret += rn; ret += string.Format(Company Name: 0 (#1), rowCompanyName, i); else foreach(GridCell cell in view.GetSelectedCells() if(rowIndex != cell.RowHandle) if(ret != ) ret += rn; ret += string.Format(Row: #0, cell.RowHandle); ret += rn + view.GetRowCellDisplayText(cell.RowHandle, cell.Column); rowIndex = cell.RowHandle; return ret; /半透明的效果 private void icbTranslucentColors_CheckedChanged(object sender, System.EventArgs e) 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;/ gridView1.ShowButtonMode = ShowButtonModeEnum.。 gridView1.OptionsBehavior.Editable = chEdit.Checked; /设置按钮是否可用/向选中的空间输入字符串 SendKeys.Send(“fsfds”);/控件焦点gridControl1.Focus();四、cardView的设置/是否现实快捷按钮CustomizeButtoncardView1.OptionsView.ShowQuickCustomizeButton=true/false;/设置CustomizeButton的能否排序和过滤foreach(GridColumn col in cardView1.Columns) col.OptionsColumn.AllowSortforeach(GridColumn col in cardView1.Columns) col.OptionsFilter.AllowFilter/card的头上的ico显示cardView1.LayoutChanged();/card的头上的标题改变显示cardView1.CardCaptionFormat =”;/cardview显示的单个记录的折叠按钮cardView1.OptionsView.ShowCardExpandButton=true;/cardView1.MaximumCardColumns =iSizecardView1.MaximumCardRows = val;cardView1.OptionsBehavior.AutoHorzWidth/多选cardView1.OptionsSelection.MultiSelect = ceMultiSelect.Checked;foreach(int i in cardView1.GetSelectedRows() DataRow row = cardView1.GetDataRow(i); if(ret != ) ret += rn; ret += string.Format(0 / 1 : 2:$#,0.00, rowTrademark, rowModel, rowPrice); /查看选择中的记录CellMerging(单元格合并的效果)/ CellMerging(单元格合并的效果)gridView1.OptionsView.AllowCellMerge = ceMerging.Checked;Fixed Bands(bandedGridView)/两边固定gridBand3 的一列的Fixed属性改成 Right,Left,None/固定与非固定列之间的距离用bandedGridView2.FixedLineWidth = (int)numFixedLineWidth.Value;/设置列的颜色l 打开Run Designer 选中Columns 选中要改变的列 里面有AppearanceCell (设置列的外观)和 AppearanceHeader(设置表格头的外观)l 或者选中该列查看“属性”里面也有这两个属性。/统计 (gridView bandedGridView通用)分组统计和全部统计:全部统计:在最下面显示统计的结果。 Run Designer-Total Summary /-General 设置显示 /-Columns 对特定列来设置统计汇总结果是否显示:可以通过gridControl的view的ShowFooter属性来设置表格下面的汇总结果分组统计:以上就是“分组”的 显示在每个分组下面来显示汇总结果。通过bandedGridView2.GroupFooterShowMode= GroupFooterShowMode.。设置分组的显示模式。/GridView设置菜单#region Grid eventsprivate void gridView1_ShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e) if(e.MenuType = DevExpress.XtraGrid.Views.Grid.GridMenuType.Column) DevExpress.XtraGrid.Menu.GridViewColumnMenu menu = e.Menu as DevExpress.XtraGrid.Menu.GridViewColumnMenu;menu.Items.Clear();if(menu.Column != null) menu.Items.Add(CreateCheckItem(Not Fixed, menu.Column, FixedStyle.None, imageList2.Images0);menu.Items.Add(CreateCheckItem(Fixed Left, menu.Column, FixedStyle.Left, imageList2.Images1);menu.Items.Add(CreateCheckItem(Fixed Right, menu.Column, FixedStyle.Right, imageList2.Images2);#endregion#region New column menuDXMenuCheckItem CreateCheckItem(string caption, GridColumn column, FixedStyle style, Image image) DXMenuCheckItem item = new DXMenuCheckItem(caption, column.Fixed = style, image, new EventHandler(OnFixedClick);item.Tag = new MenuInfo(column, style);return item;void OnFixedClick(object sender, EventArgs e) DXMenuItem item = sender as DXMenuItem;MenuInfo info = item.Tag as MenuInfo;if(info = null) return;info.Column.Fixed = info.Style;class MenuInfo public MenuInfo(GridColumn column, FixedStyle style) this.Column = column;this.Style = style;public FixedStyle Style;public GridColumn Column;#endregion/gridview cardView自动行高l 行高自动匹配 gridView1.OptionsView.RowAutoHeight = ce.Checked; cardView1.OptionsBehavior.FieldAutoHeight = ce.Checked;l 当文字多的时候(行高自动匹配 设置是才有用) repositoryItemMemoEdit1.LinesCount = ce.Checked ? 0 : 1; 设置自动全部显示该的所有行。l 图片时(行高自动匹配 设置是才有用) repositoryItemPictureEdit1.CustomHeight = ce.Checked ? 0 : 40;/BandedGridView自己订制列的方法advBandedGridView1.ColumnsCustomization();advBandedGridView1.DestroyCustomization();advBandedGridView1.OptionsCustomization.AllowChangeColumnParent = edit.Checked;advBandedGridView1.OptionsCustomization.AllowChangeBandParent = edit.Checked;advBandedGridView1.OptionsCustomization.ShowBandsInCustomizationForm = edit.Checked; /设置 图片动画模式gridView1.OptionsView.AnimationType = (GridAnimationType)/根据字段来分组模式switch(index) case 0:SetInterval(gridColumn1, ColumnGroupInterval.Alphabetical);gridColumn2.GroupInterval = ColumnGroupInterval.Alphabetical;break;case 1:SetInterval(gridColumn5, ColumnGroupInterval.DateMonth);break;case 2:SetInterval(gridColumn5, ColumnGroupInterval.DateYear);break;case 3:SetInterval(gridColumn5, ColumnGroupInterval.DateRange);break;case 4:SetSortMode(gridColumn4, ColumnSortMode.Custom);break;default:SetInterval(gridColumn2, ColumnGroupInterval.Value);break;void SetInterval(GridColumn column, ColumnGroupInterval interval) column.GroupInterval = interval;column.GroupIndex = 0;void SetSortMode(GridColumn column, ColumnSortMode sortMode) column.SortMode = sortMode;column.GroupIndex = 0;改变分组样式gridView1.OptionsView.GroupDrawMode = (GroupDrawMode)/清除分组gridView1.ClearGrouping();foreach(GridColumn column in gridView1.Columns) column.GroupInterval = ColumnGroupInterval.Default;column.SortMode = ColumnSortMode.Default;/CustomDataSummaries设置Grop private void numCustom_ValueChanged(object sender, System.EventArgs e) CustomGridView.UpdateSummary(); UpdateCaptions(numCustom.Value); private void UpdateCaptions(decimal d) CustomGridView.GroupSummary0.DisplayFormat = (Order Count WHERE Freight = + d.ToString() + = 0); OnSetCaption(); gridView2.FormatConditions0.Value1 = d; protected override void OnSetCaption(string fCaption) fCaption = count records WHERE Freight = + numCustom.Value.ToString(); if(Caption != null) Caption.Text = string.Format(0 (1), TutorialName, fCaption); /下面的效果的实现Run Designere - Style Conditions -Add -column设置列的 Condition设置条件 value1,value2是参数值 代码: public void setStyle(GridView gridView) StyleFormatCondition cn; cn = new StyleFormatCondition(FormatConditionEnum.Equal, gridView.Columnsbd_c, null,false); cn.ApplyToRow = true;/false只对列其作用。 cn.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold); cn.Appearance.ForeColor = Color.Brown; gridView.FormatConditions.Add(cn); /LayoutView layoutView1.OptionsCarouselMode.PitchAngle = (float)(int)flatFactor.EditValue) / 360.0f * 2 * Math.PI);/卡片的高度设置flatFactor.EditValue的值(0-360)layoutView1.OptionsCarouselMode.RollAngle = (float)(int)rollAngle.EditValue) / 360.0f * 2 * Math.PI);/ /卡片的旋转角度设置rollAngle.EditValue的值(0-360)layoutView1.OptionsCarouselMode.BottomCardScale = (int)endSizeScale.EditValue) / 100.0f; /卡片的距离设置endSizeScale.EditValue的值(0-100)layoutView1.OptionsCarouselMode.BottomCardAlphaLevel = (int)endAlpha.EditValue) / 100.0f;/卡片的卡片透明程度设置endAlpha.EditValue的值(0-100) layoutView1.OptionsCarouselMode.BottomCardFading = (int)bottomCardFading.EditValue) / 100.0f; /卡片的卡片褪色程度设置bottomCardFading.EditValue的值(0-100)layoutView1.OptionsCarouselMode.CardCount = (int)cardsCount.EditValue;/卡片的能显示数量设置cardsCount.EditValue的值(0-20)layoutView1.OptionsCarouselMode.InterpolationMode = (InterpolationMode)/修改卡片的方式 /layout卡片的样式在 run designer - layout里面设置 Size originalCardMinSize = Size.Empty; private void zoomTrackBarControl1_EditValueChanged(object sender, EventArgs e) if(originalCardMinSize = Size.Empty) originalCardMinSize = layoutView1.CardMinSize; double koeff = (int)zoomTrackBarControl1.EditValue) / 100.0 - 0.2; Size newSize = new Size(originalCardMinSize.Width + (int)(originalCardMinSize.Width * koeff), originalCardMinSize.Height + (int)(originalCardMinSize.Height * koeff); layoutView1.CardMinSize = newSize; /设置卡片的大小的(zoomTrackBarControl1z(0-100))下图中设置layoutView位置的方法 protected void SetMasterTableLeftPlacement() LayoutItemDragController dc = new LayoutItemDragController(masterTableItem, detailTableItem, InsertLocation.Before, LayoutType.Horizontal); DoDragItem(dc); SetMasterViewColumnLayout(); protected void SetMasterTableRightPlacement() LayoutItemDragController dc = new LayoutItemDragController(masterTableItem, detailTableItem, InsertLocation.After, LayoutType.Horizontal); DoDragItem(dc); SetMasterViewColumnLayout(); private void SetMasterTableTopPlacement() LayoutItemDragController dc = new LayoutItemDragController(masterTableItem, detailTableItem
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年美国留学入学测试题及答案
- 合作学习:高中英语阅读教学的创新引擎与实践探索
- 代写申博研究计划书合同8篇
- 2026届高考政治一轮复习统编版选必一 第四单元国际组织知识整合 课件
- 教师招聘之《小学教师招聘》模拟卷包及答案详解一套
- 教师招聘之《小学教师招聘》考试押题密卷及完整答案详解【考点梳理】
- 教师招聘之《幼儿教师招聘》模拟题库带答案详解(b卷)
- 2025年教师招聘之《幼儿教师招聘》通关试题库含答案详解(新)
- 教师招聘之《幼儿教师招聘》考试押题卷含答案详解【考试直接用】
- 押题宝典教师招聘之《小学教师招聘》考试题库含答案详解【综合卷】
- 2024年零售药店年度培训计划
- 2025浙江省知识产权研究与服务中心编外招聘12人笔试模拟试题及答案解析
- 2025国资国企穿透式监管白皮书
- 时间管理与情绪管理课件
- 医学规培读书报告
- 商家智能体产品手册和操作指南
- DB31∕T 1543-2025 快速公交(BRT)支持自动驾驶的车路协同架构与技术要求
- 渣土车制度上墙管理制度
- 调试工上岗证考试题库及答案
- 电力营销考试题库及答案
- 监察法专题培训课件
评论
0/150
提交评论