GridControl常见用法【转】
刚接触DevExpress第三方控件,把GridControl的常见用法整理一下,以供参考:
说明:
gcTest GridControl
gvText GridView
//隐藏最上面的GroupPanel 即去掉"Drag a Column Header Here To Group by that Column"
gvText.OptionsView.ShowGroupPanel = false;
//修改最上面的GroupPanel
gvText.GroupPanelText = "修改后的内容";
//单元格不可编辑
gvText.OptionsBehavior.Editable = false;
//某列标题居中 0是列索引
gvText.Columns[0].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
//某列内容居中 0是列索引
gvText.Columns[0].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
//冻结列
gvText.Columns[0].Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left;
//自动改变行高适应内容
gvText.OptionsView.RowAutoHeight = true;
//显示自动筛选行
gvText.OptionsView.ShowAutoFilterRow = false;
//不显示字表信息
gvText.OptionsView.ShowDetailButtons = false;
//显示水平滚动条,自动列宽
gvText.OptionsView.ColumnAutoWidth=false;
//自动调整列宽
gvText.BestFitColumns();
//禁用GridControl中单击列弹出右键菜单
gvText.OptionsMenu.EnableColumnMenu = false;
//禁用GridControl中列头的过滤器
gvText.OptionsCustomization.AllowFilter = false;
//禁止各列头移动
gvText.OptionsCustomization.AllowColumnMoving = false;
//禁止各列头排序
gvText.OptionsCustomization.AllowSort = false;
//禁止各列头改变列宽
gvText.OptionsCustomization.AllowColumnResizing = false;
//根据绑定的数据源自动产生列,有时可以解决GridControl记录能获取而没有显示出来的问题
gvText.PopulateColumns();
//奇偶行变色
gvText.OptionsView.EnableAppearanceEvenRow = true;
gvText.OptionsView.EnableAppearanceOddRow = true;
gvText.Appearance.EvenRow.BackColor = Color.Gray;
gvText.Appearance.OddRow.BackColor = Color.GreenYellow;
//特殊列设置 日期
string strDate="yyyy-MM-dd HH:mm";
RepositoryItemDateEdit ride = new RepositoryItemDateEdit();
ride.DisplayFormat.FormatString = strDate;
ride.EditFormat.FormatString = strDate;
ride.EditMask = strDate;
gvText.Columns["日期"].ColumnEdit = ride;
//列格式设置 decimal 价格
public const string MoneyFormatStr = "##,###,###,###,##0.00";
RepositoryItemCalcEdit rice = new RepositoryItemCalcEdit();
rice.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
rice.DisplayFormat.FormatString = MoneyFormatStr;
rice.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
rice.EditFormat.FormatString = MoneyFormatStr;
rice.EditMask = MoneyFormatStr;
gv.Columns["价格"].ColumnEdit = rice;
//给单元格赋值
gvText.SetRowCellValue(3, gvText.Columns["列名或列索引"],"要赋的值");
//添加行
gvText.AddNewRow();
//添加列
DevExpress.XtraGrid.Columns.GridColumn col = new DevExpress.XtraGrid.Columns.GridColumn();
col.Caption = "列标题";
col.FieldName = "列字段值";
col.Visible = true;
col.VisibleIndex = gvText.Columns.Count;
gvText.Columns.Add(col);
/// <summary>
/// 获取选定行指定列单元格的值
/// </summary>
/// <param name="str">指定列的列名</param>
/// <returns>单元格的值</returns>
public string GetCellValue(string str) {
int[] pRows = this.gvText.GetSelectedRows();
if (pRows.GetLength(0) > 0){
return gvText.GetRowCellValue(pRows[0], str).ToString();
}
else {
return null;
}
}
GridControl常见用法【转】的更多相关文章
- DevExpress 控件 GridControl常见用法
刚接触DevExpress第三方控件,把GridControl的常见用法整理一下,以供参考: 说明: gcTest GridControl gvText GridView //隐藏最上面的G ...
- Linux中find常见用法
Linux中find常见用法示例 ·find path -option [ -print ] [ -exec -ok command ] {} \; find命令的参数 ...
- php中的curl使用入门教程和常见用法实例
摘要: [目录] php中的curl使用入门教程和常见用法实例 一.curl的优势 二.curl的简单使用步骤 三.错误处理 四.获取curl请求的具体信息 五.使用curl发送post请求 六.文件 ...
- Guava中Predicate的常见用法
Guava中Predicate的常见用法 1. Predicate基本用法 guava提供了许多利用Functions和Predicates来操作Collections的工具,一般在 Iterabl ...
- find常见用法
Linux中find常见用法示例 ·find path -option [ -print ] [ -exec -ok command ] {} \; find命令的参数 ...
- iOS 开发多线程篇—GCD的常见用法
iOS开发多线程篇—GCD的常见用法 一.延迟执行 1.介绍 iOS常见的延时执行有2种方式 (1)调用NSObject的方法 [self performSelector:@selector(run) ...
- iOS开发多线程篇—GCD的常见用法
iOS开发多线程篇—GCD的常见用法 一.延迟执行 1.介绍 iOS常见的延时执行有2种方式 (1)调用NSObject的方法 [self performSelector:@selector(run) ...
- [转]EasyUI——常见用法总结
原文链接: EasyUI——常见用法总结 1. 使用 data-options 来初始化属性. data-options是jQuery Easyui 最近两个版本才加上的一个特殊属性.通过这个属性,我 ...
- NSString常见用法总结
//====================NSStirng 的常见用法==================== -(void)testString { //创建格式化字符串:占位符(由一个%加一个字 ...
随机推荐
- Eth-Trunk链路聚合配置
Eth-Trunk概述 Eth-Trunk接口能够实现负载分担.增加带宽和提高可靠性 Eth-Trunk接口把多个物理接口捆绑成一个逻辑接口 Eth-Trunk接口的链路聚合模式 链路聚合模式 应用场 ...
- BZOJ 1009 HNOI 2008 GT考试 递推+矩乘
1009: [HNOI2008]GT考试 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 3679 Solved: 2254[Submit][Statu ...
- Codeforces Round #374 (Div. 2) B. Passwords 贪心
B. Passwords 题目连接: http://codeforces.com/contest/721/problem/B Description Vanya is managed to enter ...
- 自己封装jquery的一些方法 链式调用模式
function getIndex(ele){ var parent=ele.parentNode; var brothers=parent.children; for(var i=0,len=bro ...
- 用css解决table文字溢出控制td显示字数(转)
场景: 最左边这栏我不行让他换行,怎么办呢? 下面是解决办法: table{ width:100px; table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义 ...
- 关于ConcurrentDictionary的线程安全
ConcurrentDictionary是.net BCL的一个线程安全的字典类,由于其方法的线程安全性,使用时无需手动加锁,被广泛应用于多线程编程中.然而,有的时候他们并不是如我们预期的那样工作. ...
- 使用MSTest进行单元测试
我之前写过一篇XUNit的简介:使用Xunit来进行单元测试.Xunit在当时确实是一个最简单易用的测试框架,然而,随着发展,Xunit也变得复杂了不少,光写一个最简单的测试就要导入8个包. 如果在大 ...
- Introduction to Cortex Serial Wire Debugging
Serial Wire Debug (SWD) provides a debug port for severely pin limited packages, often the case for ...
- Golang 版本发布 与 TIOBE 排名
2016年国庆节(10月1日)开始接触 Go 语言,记录一下它的 版本发布 与 TIOBE 排名: Golang 排行榜 月份 版本 排名 备注 2012.03 1.0 201 ...
- AngularJS自定义Directive与controller的交互
有时候,自定义的Directive中需要调用controller中的方法,即Directive与controller有一定的耦合度. 比如有如下的一个controller: app.controlle ...