Dev控件使用
更新时间:2024-04-26 11:06:01 阅读量: 综合文库 文档下载
1 TreeList控件
1.1 设置TreeList控件外观样式显隐
在TreeList控件属性OptionsView中设置,可设置标题列、左侧边表格框、表格线等显隐
1.2 新增节点后,节点选中
01.tv.BeginUnboundLoad();
02. TreeListNode node = tv.AppendNode(null, tv.FocusedNode);
03. node[colVC_FENLEI_ID] = item.VC_FENLEI_ID;
04. node[colVC_FENLEI_NAME] = item.VC_FENLEI_NAME; 05. node[colVC_PINYIN_CODE] = item.VC_PINYIN_CODE; 06. node[colVC_SHANGJI_ID] = item.VC_SHANGJI_ID; 07. node[colVC_TAOSHU_ID] = item.VC_TAOSHU_ID; 08. node[colN_JIBIE_CODE] = item.N_JIBIE_CODE; 09. if
(!string.IsNullOrEmpty(item.VC_YOUXIAO_FLAG)) 10. {
11. node[colVC_YOUXIAO_FLAG] = Convert.ToInt32(item.VC_YOUXIAO_FLAG); 12. } 13.
14. tv.EndUnboundLoad(); 15. tv.SetFocusedNode(node);
16. FocusedNodeChangedEventArgs args = new FocusedNodeChangedEventArgs(null, tv.FocusedNode); 17. tv_FocusedNodeChanged(tv, args);
上面代码是设置下级节点,同级的使用选中节点的父级节点作为父节点,没有就是null,不过如果没有父级节点,将导致新增后无法选中,目前没有找到解决办法。
2 GridControl
2.1 GridView视图
2.1.1 禁用GridControl中单击单元格弹出右键菜单
ContextMenu emptyMenu = new ContextMenu(); ///
/// 去除单元格选中后出现的系统右键菜单 ///
///
private void gridView1_ShownEditor(object sender, EventArgs e) {
GridView view = sender as GridView;
view.ActiveEditor.ContextMenu = emptyMenu; }
2.1.2 如何禁用GridControl中单击列弹出右键菜单
设置Run Design->OptionsMenu->EnableColumnMenu 设置为:false
2.1.3 将列标题居中
选中列,在属性AppearanceHeader中的TextOptions,如图:
2.1.4 设置GridControl中数据导航显隐
效果:
2.1.5 GridControl编辑完成后,立即获取所编辑行的数据
gridView1.CloseEditor();
gridView1.UpdateCurrentRow();
2.1.6 如何解决单击记录整行选中的问题
View->OptionsBehavior->EditorShowMode 设置为:Click
2.1.7 如何新增一条记录
(1)、gridView.AddNewRow() (2)、实现gridView_InitNewRow事件
2.1.8 如何解决GridControl记录能获取而没有显示出来的
问题
gridView.populateColumns();
2.1.9 如何让行只能选择而不能编辑(或编辑某一单元格)
(1)、View->OptionsBehavior->EditorShowMode 设置为:Click (2)、View->OptionsBehavior->Editable 设置为:false
2.1.10 如何禁用GridControl中单击列弹出右键菜单
设置Run Design->OptionsMenu->EnableColumnMenu 设置为:false
2.1.11 如何隐藏GridControl的GroupPanel表头
设置Run Design->OptionsView->ShowGroupPanel 设置为:false
2.1.12 如何禁用GridControl中列头的过滤器
过滤器如下图所示:
设置 Run Design->OptionsCustomization->AllowFilter 设置为:false
2.1.13 如何在查询得到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(\宋体\
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(\宋体\
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); } } }
2.1.14 如何显示水平滚动条?
设置this.gridView.OptionsView.ColumnAutoWidth = false;
2.1.15 如何定位到第一条数据/记录?
设置 this.gridView.MoveFirst()
2.1.16 如何定位到下一条数据/记录?
设置 this.gridView.MoveNext()
2.1.17 如何定位到最后一条数据/记录?
设置 this.gridView.MoveLast()
2.1.18 设置成一次选择一行,并且不能被编辑
this.gridView1.FocusRectStyle =
DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus; this.gridView1.OptionsBehavior.Editable = false;
this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
2.1.19 如何显示行号?
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(); } }
2.1.20 如何让各列头禁止移动?
设置gridView1.OptionsCustomization.AllowColumnMoving = false;
2.1.21 如何让各列头禁止排序?
设置gridView1.OptionsCustomization.AllowSort = false;
2.1.22 如何禁止各列头改变列宽?
设置gridView1.OptionsCustomization.AllowColumnResizing = false;
2.1.23 DevExpress GridView属性设置总结(图文)
作者:lir 出处:叉叉哥的BLOG-CSDN 2012/10/11 14:29:37 阅读 382 次
2.1.23.1 概述:最近在使用GridView做一个小项目,以下是本人
使用过程中的个人总结,本文主要总结控件的属性设置,附上图片,给大家一个参考。后续会给大家分享功能实现和使用的小技巧。
最近在使用GridView做一个小项目,以下是本人使用过程中的个人总结,本文主要总结控件的属性设置,附上图片,给大家一个参考。后续会给大家分享功能实现和使用的小技巧。
GirdControl是数据的容器,它包含多种显示方式,GridView则是一种二维表格视图。 绑定数据源:
List
属性设置:
Visual Studio设计进入”Run Designer”,可以打开属性设置的窗口。
1.OptionsView
ShowGroupPanel =false; //去掉表格上方“Drag a column header ??”
ShowIndicator = false; //不显示最左边一列空白列
ShowColumnHeaders =false;//不显示列标题栏
ColumnAutoWidth =false; //不设置自动列宽(这样的话表格下方可能会出现滚动条或者未铺满)
AllowCellMerge =true; //是否自动合并单元格
//设置行颜色交替
EnableAppearanceEvenRow = true; //偶数行颜色变化 EnableAppearanceOddRow = true; //奇数行颜色变化 此处交替变化的行背景色也可以设置,见第6条。 2.OptionsBehavior
Editable = false; //设置单元格不可编辑 3.OptionsSelection
EnableAppearanceFocusedCell = false; //设置单元格不能选择(如果不设置,则点击到的单元格在整行选择情况下的背景色不变)
EnableAppearanceFocusedRow= false; //禁止选择行
MultiSelect = true; //设置可多选
MultiSelectMode =CellSelect/RowSelect;//多选行还是多选单元格(一般选RowSelect) 4. OptionsMenu
EnableColumnMenu =false; //禁用右击表格标题行弹出的菜单 5. OptionsCustomization //禁用标题行过滤
AllowFilter = false;
//禁用标题行排序
AllowSort = false;
//禁止列移动
AllowColumnMoving = false;
//禁止改变列宽
AllowColumnResizing = false;
6.Appearences
SelectedRow & FocusedRow(以下两项要同时设置):设置选中行背景色 BackColor :MediumSlateBlue //背景色 ForeColor : White //前景色(字体颜色)
HeaderPanel:设置标题行颜色 BackColor : Black //背景色
ForeColor : White //前景色(字体颜色)
仅设置以上两项无法改变标题行的颜色,还需要设置控件的LookAndFeel 选中GridControl,在属性中找到LookAndFeel并展开, Style设为UltraFlat,UseDefualtLookAndFeel设为false。
OddRow EvenRow:设置奇数行、偶数行颜色
EnableAppearanceEvenRow、EnableAppearanceOddRow这两项对应设置才有效 Row:这个就不用多说了。。。 7.其他
RowHeight //行高
ColumnPanelRowHeight //标题行的行高
FocusRectStyle = None; //取消点击后的虚线框,下图
2.1.24 数据折行
改变视图模式
2.1.25 Devexpress GridControl [一篮饭特稀原创,转载请注明出处http://www.cnblogs.com/wanghafan/archive/2012/02/09/2344241.html] --Devexpress GridControl repositoryItemCalcEdit 数值 不为空 View Code 1 AllowNullInput=False; --Devexpress GridControl GridView 点击 单元格 选中内容 View Code 1 GridView-OptionsBehavior-EditorShowMode设置成MouseUp 2 3 另外如果是treeList则设置treeList-OptionsBehavior-ShowEditorOnMouseUp为True --Devexpress GridControl 向上 向下 最上 最下 排序 View Code 1 private void toolStripButton_向上_Click(object sender, EventArgs e) 2 { 3 UpOrDown(gridView, true); 4 } 5 6 private void toolStripButton_向下_Click(object sender, EventArgs e) 7 { 8 UpOrDown(gridView, false); 9 } 10 11 private void toolStripButton_最下_Click(object sender, EventArgs e) 12 { 13 TopOrLast(gridView, false); 14 } 15 16 private void toolStripButton_最上_Click(object sender, EventArgs e) 17 { 18 TopOrLast(gridView, true); 19 } 20 21 private void UpOrDown(DevExpress.XtraGrid.Views.Grid.GridView GridView, bool ISUpOrDown) 22 {
23 DataRow row = GridView.GetFocusedDataRow(); 24 if (ISUpOrDown) 25 {
26 if (!GridView.IsFirstRow) 27 GridView.MovePrev(); 28 else 29 return; 30 } 31 else 32 {
33 if (!GridView.IsLastRow) 34 GridView.MoveNext(); 35 else 36 return; 37 }
38 DataRow Pretrow = GridView.GetFocusedDataRow(); 39 if (Pretrow != null && row != null) 40 {
41 DataRow IRow = dt_F_表格编号.NewRow();
42 for (int k = 0; k < row.ItemArray.Length; k++) IRow[k] = Pretrow[k];
43 for (int i = 0; i < row.ItemArray.Length; i++) Pretrow[i] = row[i]; 44 for (int j = 0; j < row.ItemArray.Length; j++) row[j] = IRow[j]; 45 } 46 } 47
48 private void TopOrLast(DevExpress.XtraGrid.Views.Grid.GridView GridView, bool ISTopOrLast) 49 {
50 int rowA = GridView.FocusedRowHandle; 51 int rowB = 0; 52 if (ISTopOrLast) 53 {
54 if (!GridView.IsFirstRow) 55 {
56 GridView.MoveFirst();
57 rowB = GridView.FocusedRowHandle; 58 } 59 else 60 return; 61 } 62 else 63 {
64 if (!GridView.IsLastRow) 65 {
66 GridView.MoveLast();
67 rowB = GridView.FocusedRowHandle; 68 } 69 else 70 return; 71 } 72
73 if (rowA!=rowB) 74 {
75 if (rowA < rowB) //最下 76 {
77 for (int z = rowA+1; z <= rowB; z++) 78 {
79 DataRow row = gridView.GetDataRow(rowA); 80 DataRow newrow = gridView.GetDataRow(z); 81 DataRow IRow = dt_F_表格编号.NewRow();
82 for (int k = 0; k < row.ItemArray.Length; k++) IRow[k] = newrow[k];
83 for (int i = 0; i < row.ItemArray.Length; i++) newrow[i] = row[i];
84 for (int j = 0; j < row.ItemArray.Length; j++) row[j] = IRow[j];
85 rowA++; 86 } 87 }
88 else //最上 89 {
90 for (int z = rowA-1; rowB>=0; z--) 91 {
92 DataRow row = gridView.GetDataRow(rowA); 93 DataRow newrow = gridView.GetDataRow(z); 94 DataRow IRow = dt_F_表格编号.NewRow();
95 for (int k = 0; k < row.ItemArray.Length; k++) IRow[k] = newrow[k];
96 for (int i = 0; i < row.ItemArray.Length; i++) newrow[i] = row[i];
97 for (int j = 0; j < row.ItemArray.Length; j++) row[j] = IRow[j];
98 rowA--;
99 if (z == 0) return; 100 }
101 }
102 } 103 }
--Devexpress GridControl 滚动条
View Code
1 GridControl-Run Designer-OptionsView-ColunmAutoWidth=False
--Devexpress GridControl 单元格 只读
View Code
1 控件本身不支持单个单元格的只读效果,只能实现整列的只读,因此我们自己虚拟只读效果 2 3 {
4 if (e.Column != this.gc) 5 {
6 DataRow dataRow = this.gridView.GetDataRow(e.RowHandle);
7 if ((dataRow != null) && (dataRow[e.Column.FieldName] is DBNull)) 8 {
9 e.RepositoryItem = this.repositoryItemHyperLinkEdit_ReadOnly; //这个是一个单元格控件设置成只读 控件为hyperLintEdit才可以设置成不可聚焦TextEidtStyle=HideTextEditor 10 } 11 } 12 } 13
14 private void gridView_RowCellStyle(object sender, RowCellStyleEventArgs e) 15 {
16 if (e.Column != this.gc) 17 {
18 DataRow dataRow = this.gridView.GetDataRow(e.RowHandle);
19 if ((dataRow != null) && (dataRow[e.Column.FieldName] is DBNull)) 20 {
21 e.Appearance.BackColor = this.gc.AppearanceCell.BackColor; //设置单元格颜色为灰色 当然也可以不设置 22 } 23 } 24 } 25 26
27 private void InitializeComponent()
private
void
gridView_CustomRowCellEdit(object
sender,
CustomRowCellEditEventArgs e)
28 {
29 this.repositoryItemTextEdit = new RepositoryItemTextEdit(); 30 this.repositoryItemTextEdit.BeginInit();
31 this.repositoryItemTextEdit.Appearance.BackColor = Color.FromArgb(0xdf, 0xdf, 0xdf);
32 this.repositoryItemTextEdit.Appearance.Options.UseBackColor = true; 33
this.repositoryItemTextEdit.AppearanceDisabled.BackColor
=
Color.FromArgb(0xdf, 0xdf, 0xdf);
34 this.repositoryItemTextEdit.AppearanceDisabled.Options.UseBackColor = true; 35
this.repositoryItemTextEdit.AppearanceFocused.BackColor
=
Color.FromArgb(0xdf, 0xdf, 0xdf);
36 this.repositoryItemTextEdit.AppearanceFocused.Options.UseBackColor = true;
37 this.repositoryItemTextEdit.AutoHeight = false; 38 this.repositoryItemTextEdit.Enabled = false;
39 this.repositoryItemTextEdit.Name = \; 40 this.repositoryItemTextEdit.ReadOnly = true;
41 this.repositoryItemTextEdit.AllowNullInput=false; //不允许空值 42 this.repositoryItemTextEdit.EndInit(); 43 }
--Devexpress GridControl 多行复制
View Code
1 Devexprss GridControl 多行复制: 2 1.GridControl设计器Views下
3 OptionsBehavior-CopyToClipboardWithColumnHeaders=False; 4 OptionsSelection-MultiSelect=True;
5 OptionsSelection-MultiSelectMode=RowSelect; 6 2.添加如下代码 7 8 {
9 e.Cancel = isCancel; 10 }
11 bool isCancel = true; 12 13 {
14 isCancel = false; 15 }
private
void
Table3Three_gridView_RowClick(object
sender,
DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
private
void
Table3Three_gridView_ShowingEditor(object
sender,
CancelEventArgs e)
16 private void Table3Three_gridView_KeyDown(object sender, KeyEventArgs e) 17 {
18 //Ctrl+V粘贴
19 if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.V) 20 {
21 object _objData = null;
22 IDataObject dataObj = Clipboard.GetDataObject(); 23
24 if (dataObj.GetDataPresent(DataFormats.Text)) 25 _objData = dataObj.GetData(DataFormats.Text); 26
27 if (_objData != null) 28 {
29 int RowNumber = 0; 30
31 string _tempStr = _objData.ToString(); 32
33 string[] _split = { \ };
34 string[] _arrayStr = _tempStr.Split(_split, StringSplitOptions.None); 35
36 for (int i = 0; i < _arrayStr.Length - 1; i++) 37 {
38 string[] _arrayStr2 = _arrayStr[i].Split('\\t'); 39
40 Table3Three_gridView.AddNewRow(); 41 Table3Three_gridView.MoveLastVisible();
42 RowNumber = Table3Three_gridView.FocusedRowHandle; 43 44 45 46 47 48 49 50 51
Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber,
Table3Three_gridView.Columns[\定额编号\], _arrayStr2[0]); Table3Three_gridView.Columns[\定额名称\], _arrayStr2[1]); Table3Three_gridView.Columns[\单位\], _arrayStr2[2]); Table3Three_gridView.Columns[\名称\], _arrayStr2[3]); Table3Three_gridView.Columns[\单位台班\], _arrayStr2[4]); Table3Three_gridView.Columns[\计算数量\], _arrayStr2[5]); Table3Three_gridView.Columns[\台班单价\], _arrayStr2[6]); Table3Three_gridView.Columns[\备注\], _arrayStr2[7]);
52 53 54 55
Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber, Table3Three_gridView.SetRowCellValue(RowNumber,
Table3Three_gridView.Columns[\仪器仪表编码\], _arrayStr2[8]); Table3Three_gridView.Columns[\总数量\], _arrayStr2[9]); Table3Three_gridView.Columns[\台班合价\], _arrayStr2[10]); Table3Three_gridView.Columns[\关联\], _arrayStr2[11]); 56 }
57 isCancel = true;
58 App_Code.Global.isChange = \; 59 } 60 } 61 }
--Devexpress GridControl AdvBandedGridView 数据多行显示
View Code
1 实现效果:
2 |基本信息| 费率 | 3 | 名称 | 运杂费 |采购费 | 4 | |优惠系数|优惠系数| 5 | 第1段 | 2.2% | 1.0% | 6 | | 80% |90% | 7 8 操作:
9 1.GridView设计器“ClickHereToChangeView-ConvertTo-advBandedGridView” 10 2.GridControl设计器中Bands新增“基本信息”和“费率”两个Band
11 3.GridControl设计器中Bands中ShowColumnsSelector并拖动“运杂费”“采购费”“优惠系数”“优惠系数”到各自的Bands
12 3.GridControl设计器中Bands拖动2个优惠系数分别到第二行 13 4.GridControl设计器中Columns修改“名称”列rowcount属性为2 14 5.GridControl设计器中Bands和Columns所有列的MinWidth=100 15 6.GridControl设计器中Bands和Columns所有列的AllowMove=false 16 7.GridControl设计器中Bands中AutoWidth的勾去掉
--Devexpress GridControl RepositoryItemComboBox 只读
View Code
1 GridControl 的RepositoryItemComboBox 控件,如果需要设置“只读+下拉”方法如下: 2
GridControl
设
计
器
-Columns-某
字
段
-Column
properties-ColumnEdit-TextEditStyle=DisableTextEditor --Devexpress GridControl 统计技巧 View Code 1 比如对“数量”列进行统计,只要在GridControl的设计器中设置SummaryItem: 2 SummaryItem.DisplayFormat = \; 3 SummaryItem.FieldName = \数量\; 4 SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; --Devexpress GridControl 公式使用技巧 View Code 1 1.GridControl设计器 //由于数据库的列“合价”不能既有值又绑定公式,所以我们引入一个虚拟的列“小计” 2 SQL语句“select 单价,数量,合价 from 表名” 3 数据库真实列“单价”“数量”“合价”,非真实列“小计” 4 其中“小计”UnboundExpression=[单价] * [数量] 5 其中“小计”Visible=False //隐藏该虚拟列 6 2.后台代码 //把“小计”计算的值写入“合价”单元格 7 private void gridView_CellValueChanged(object sender, CellValueChangedEventArgs e) 8 { 9 if (gridView.FocusedRowHandle >= 0) 10 { 11 if (e.Column.Caption.Equals(\数量\) || e.Column.Caption.Equals(\单价\)) 12 { 13 //设置结果值 14 gridView.SetRowCellValue(gridView.FocusedRowHandle, gridView.Columns[\合价\], gridView.GetFocusedRowCellValue(\小计\).ToString()); 15 } 16 } 17 } --Devexpress GridControl 屏蔽右键 View Code --Devexpress GridControl 全选
1.如图添加DevExpress.XtraEditors.CheckEdit,设置Size(18, 19) 2.设置GridControl首列“check”属性MinWidth,MaxWidth为20 3.添加代码 View Code 1 private void checkBox_All_CheckStateChanged(object sender, EventArgs e) 2 { 3 foreach (DataRow dr in dt_EvaluateProjectT.Rows) 4 dr[\]=(sender as DevExpress.XtraEditors.CheckEdit).CheckState; 5 }
2.1.26 设置所有列居中
所有标题居中,gridView——Appearance——HeaderPanel——TextOptions 所有数据列居中,gridView——Appearance——Row——TextOptions
2.1.27 GridView设置HyperLinkEdit、ComboEdit文本编辑模
式
TextEditStyle文本编辑模式
2.1.28 设置鼠标选中单元格值
2.1.29 在Planner.NET的MonthRange视图中,是否存在一种显
示方式将星期一显示为每周的第一天?
您可以使用 Calendar.Culture 属性指定每周的第一天为星期一,或者像下面的示例代码那样直接通过 Calendar.DateTimeFormat 属性设置每周的第一天: Code:
calendar.BeginInit();
calendar.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday; calendar.EndInit();
您也可以通过属性网格在设计阶段执行这个改变。
2.1.30 调整标题列和行高度,标题列折行
标题列高度 gridView——ColumnPanelRowHeigh
标题列折行 gridColumn——AppearanceHeader—— TextOptions——WordWrap
调整行的高度:gridView——RowHeight
2.1.31 改变某行背景颜色
private void gridView1_RowStyle(object DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) {
int hand = e.RowHandle; if (hand < 0) return;
DataRow dr = this.gridView1.GetDataRow(hand); if (dr== null) return; if (“满足条件”) {
e.Appearance.ForeColor = Color.Red;// 改变行字体颜色 e.Appearance.BackColor = Color.Red;// 改变行背景颜色 e.Appearance.BackColor2 = Color.Blue;// 添加渐变颜色 //……
sender,
//根据需求
} }
2.1.32 GridView LookUpEdit获取单元格显示值
GridView的GetRowCellDisplayText方法获取。
2.1.33 GridView SearchLookUpEdit获取值
在BarManager的MainMenu上添加SearchLookUpEdit(lueSearch),它是BarEditItem(beiSearch)项下的内置控件
1.给内置控件SearchLookUpEdit(lueSearch)或者BarEditItem(beiSearch)绑定数据源
2.BarEditItem(beiSearch)值改变后,在EditValueChanged中,获取BarEditItem(beiSearch)中的内容,比如:ValueMember=“Id”,
DisplayMember=\中显示的是name的值,但是怎么通过SearchLookUpEdit(lueSearch)或者BarEditItem(beiSearch)获取出来 3、BarEditItem(beiSearch)值改变后,不在EditValueChanged中获取选择的值,而是在BarManager别的BarButtonItem(btnSearch)下的事件中获取BarEditItem(beiSearch)中显示的值
关键字:DevExpress
提示:不能回答自己的问题 慧都专家答案
\请通过RepositoryItemSearchLookUpEdit.DataSource属性绑定数据源 2.请通过(sender as SearchLookUpEdit).Text属性获取 3.请使用 BarEditITem.Edit.GetDisplayText 获取\
2.1.34 GridView固定列宽
1.OptionsView
ShowGroupPanel =false; //去掉表格上方“Drag a column header ??”
ShowIndicator = false; //不显示最左边一列空白列
ShowColumnHeaders =false;//不显示列标题栏
ColumnAutoWidth =false; //不设置自动列宽(这样的话表格下方可能会出现滚动条或者未铺满)
AllowCellMerge =true; //是否自动合并单元格
//设置行颜色交替
EnableAppearanceEvenRow = true; //偶数行颜色变化 EnableAppearanceOddRow = true; //奇数行颜色变化 此处交替变化的行背景色也可以设置,见第6条。 2.OptionsBehavior
Editable = false; //设置单元格不可编辑 3.OptionsSelection
EnableAppearanceFocusedCell = false; //设置单元格不能选择(如果不设置,则点击到的单元格在整行选择情况下的背景色不变)
EnableAppearanceFocusedRow= false; //禁止选择行
MultiSelect = true; //设置可多选
MultiSelectMode =CellSelect/RowSelect;//多选行还是多选单元格(一般选RowSelect) 4. OptionsMenu
EnableColumnMenu =false; //禁用右击表格标题行弹出的菜单 5. OptionsCustomization //禁用标题行过滤
AllowFilter = false;
//禁用标题行排序
AllowSort = false;
//禁止列移动
AllowColumnMoving = false;
//禁止改变列宽
AllowColumnResizing = false; 6.Appearences
SelectedRow & FocusedRow(以下两项要同时设置):设置选中行背景色 BackColor :MediumSlateBlue //背景色 ForeColor : White //前景色(字体颜色)
HeaderPanel:设置标题行颜色
BackColor : Black //背景色
ForeColor : White //前景色(字体颜色)
仅设置以上两项无法改变标题行的颜色,还需要设置控件的LookAndFeel 选中GridControl,在属性中找到LookAndFeel并展开, Style设为UltraFlat,UseDefualtLookAndFeel设为false。
OddRow EvenRow:设置奇数行、偶数行颜色
EnableAppearanceEvenRow、EnableAppearanceOddRow这两项对应设置才有效 Row:这个就不用多说了。。。 7.其他
RowHeight //行高
ColumnPanelRowHeight //标题行的行高
FocusRectStyle = None; //取消点击后的虚线框,下图
2.1.35 GridView导出选中行
2.2 LayoutView视图 2.2.1 自定义改变卡片标题名称
private void layoutView1_CustomDrawCardCaption(object sender,
DevExpress.XtraGrid.Views.Layout.Events.LayoutViewCustomDrawCardCaptionEventArgs e) {
e.CardCaption =
layoutView1.GetRowCellValue(e.RowHandle,\).ToString(); }
3 BarManager
3.1 设置菜单中文字和图片共同存在
在菜单中右键,在右键菜单中选择设置
3.2 隐藏菜单自定义
3.3 隐藏菜单项自定义
4 LookUpEdit
4.1 绑定数据
lueCowNumber.Properties.ValueMember = \; lueCowNumber.Properties.DisplayMember = \; lueCowNumber.Properties.DataSource = GetCowInf(); lueCowNumber.EditValue = \;//初始文本框值为空
lueCowNumber.Properties.AutoSearchColumnIndex = 1;//以索引为1的列检索 lueCowNumber.Properties.TextEditStyle = TextEditStyles.Standard;//单元格标准模式编辑
5 内置ComboBoxEdit(treeList、GridControl、BarManager)
5.1 初始化设置默认值
//获取指定索引的值
string value = repositoryItemComboBox1.Items[1].ToString();
repositoryItemComboBox1.NullText = value; 或者
gridView1.SetRowCellValue(e.FocusedRowHandle,
gridView1.Columns[tb_event_PregnancyCheck.CheckResult],
(((RepositoryItemComboBox)gridView1.Columns[tb_event_PregnancyCheck.CheckResult].ColumnEdit).Items[0]));
5.2 下拉列表改变时,获取选中项的索引
BaseEdit logicEdit =barManager1.ActiveEditor;//获取当前激活编辑器对象 ComboBoxEdit co = (ComboBoxEdit)logicEdit;//将该对象转换为ComboBoxEdit对象
gcCowInf.DataSource = GetSemenCowInf(co.SelectedIndex);//根据选择的索引获取对一个的值
5.3 下拉列表只能选择,不能编辑
6 DateEdit 日期控件
6.1 DevExpress DateEdit控件如何实现日期格式化显
示 ?
1、需要显示的日期为2012年3月12日需要如下设置 2、 Properties-Mask-EditMark [yyyy年MM月dd日] 3、 Properties-Mask-UseMarkAsDisplay [True]
6.2
7 SearchLookUpEdit
7.1 SearchLookUpEdit 获取绑定数据源中其中一列的值
GridView view = lueGroup.Properties.View; int rowHandle = view.FocusedRowHandle; string fieldName = \
object value = view.GetRowCellValue(rowHandle, fieldName);\
8 textEdit
8.1 回车后鼠标指针移开
第一步:
第二步:
private void riTxtCowNum_Validating(object sender, CancelEventArgs e) {
e.Cancel = true; }
正在阅读:
Dev控件使用04-26
安徽工业大学校园网Windows XP和Windows 7(Vista)中L2TP客户端的设置01-25
感恩作文200字04-01
失业保险历年考题2007年11月05-03
佛说阿难四事经(白话文)01-26
4.1指南针为什么能指方向(1)09-01
乌龟和兔子的故事作文600字06-27
勤劳小学生作文06-15
2022年安徽师范大学Z0406专业基础知识(主要考察现代汉语,中国国04-09
初中数学中考模拟试卷及答案 (28)03-08
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 控件
- 使用
- Dev