DEV 控件之GridControl
CheckEdit 控件 :
获取行 多选框中的值:
需要先关闭修改 既GridView.CloseEditor();
var value = GridView.GetDataRow(i)["FieldName"].ToString();
获取单元格的值方法:
DataTabe dt = (DataTabe)GridControl.DataSouse;
//遍历行
for(int i=0; i<dt.Rows.Count ;i++)
{
//单元格的值
string fieldname1 = dr["FieldName].ToString();
string fieldname2 = GridView.GetDataRow(i)["FieldName"].ToString();
}
对某列添加下拉菜单(ColumnEdit:PopupContainerEdit)
(列的下拉菜单)
需要展示菜单则需要给菜单添加容器
给PopupContainerEdit 下拉按钮添加PopupCpntrol
并通过给PopupContainerEdit.QueryPopUp事件设定Popup容器的大小触发展示效果。
获取焦点并填入数据
gvwData.SetRowCellValue(gvwData.FocusedRowHandle, "PreAreaCode", args.KeyValue["AreaCode"]); //获取焦点并填入数据
//当前行数据
DataRow dr = gvwData.GetDataRow(gvwData.GetFocusedDataSourceRowIndex()); //获取焦点行数据
//获取焦点行序列
int index = gvwData.GetFocusedDataSourceRowIndex();//获取焦点行序列
获取行焦点
this.gvwData.FocusedRowHandle = i; //i 为行序列号
获取单元格行焦点
this.gvwData.FocusedColumn = this.gvwData.Columns["FieldName"]; // FieldName --列名
关闭Popup
PopupContainerCIQNo.OwnerEdit.ClosePopup();
GridView
#region 显示明细行号
/// <summary>
/// 显示明细行号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gvwData_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
if (e.Info.IsRowIndicator)
{
if (e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
}
}
#endregion
#region 禁止 Popup 弹出 如果X>1 禁止Popup 弹出
private void editorGoodsCode_QueryPopUp_1(object sender, CancelEventArgs e)
{
if (x>1)
{
e.Cancel = true;
return;
}
if (sender is PopupContainerEdit)
{
PopupContainerEdit edit = (PopupContainerEdit)sender;
PopupContainerControl control = edit.Properties.PopupControl;
control.Width = 800;
control.Height = 600;
popupInStoreLine1.GoodsOwnerCode = cmbGoodsOwnerCode.EditValue.ToString();
}
}
#endregion
#region 设置 POPUP 大小
private void PopupContainerEdit_QueryPopUp(object sender, System.ComponentModel.CancelEventArgs e)
{
PopupContainerEdit edit = (PopupContainerEdit)sender;
PopupContainerControl control = edit.Properties.PopupControl;
control.Width = 800;
control.Height = 600;
}
#endregion
//分页查询
public static PageInfo GetDataByConditions(string GOCode, string GOName)
{
PageInfo pageInfo = new PageInfo();
pageInfo.RecordCountSQL = @"SELECT COUNT(1) FROM dbo.DataTable
WHERE 1 = 1 ";
pageInfo.RecordSQL = @"SELECT * FROM dbo.DataTable WHERE 1 = 1 ";
string strWhere = string.Empty;
List<object> paraValues = new List<object>();
// 分类代码
if (!String.IsNullOrEmpty(GOCode))
{
strWhere += " AND A.GOCode LIKE @P0";
paraValues.Add("%" + GOCode + "%");
}
// 分类名称
if (!String.IsNullOrEmpty(GOName))
{
strWhere += " AND A.GOName LIKE @P1";
paraValues.Add("%" + GOName + "%");
}
pageInfo.RecordCountSQL = pageInfo.RecordCountSQL + strWhere;
pageInfo.RecordSQL = pageInfo.RecordSQL + strWhere;
pageInfo.Parameters = paraValues;
return pageInfo;
}
CheckEdit 控件 :
获取行 多选框中的值:
需要先关闭修改 既GridView.CloseEditor();
var value = GridView.GetDataRow(i)["FieldName"].ToString();
获取单元格的值方法:
DataTabe dt = (DataTabe)GridControl.DataSouse;
//遍历行
for(int i=0; i<dt.Rows.Count ;i++)
{
//单元格的值
string fieldname1 = dr["FieldName].ToString();
string fieldname2 = GridView.GetDataRow(i)["FieldName"].ToString();
}
对某列添加下拉菜单(ColumnEdit:PopupContainerEdit)
(列的下拉菜单)
需要展示菜单则需要给菜单添加容器
给PopupContainerEdit 下拉按钮添加PopupCpntrol
并通过给PopupContainerEdit.QueryPopUp事件设定Popup容器的大小触发展示效果。
获取焦点并填入数据
gvwData.SetRowCellValue(gvwData.FocusedRowHandle, "PreAreaCode", args.KeyValue["AreaCode"]); //获取焦点并填入数据
//当前行数据
DataRow dr = gvwData.GetDataRow(gvwData.GetFocusedDataSourceRowIndex()); //获取焦点行数据
//获取焦点行序列
int index = gvwData.GetFocusedDataSourceRowIndex();//获取焦点行序列
获取行焦点
this.gvwData.FocusedRowHandle = i; //i 为行序列号
获取单元格行焦点
this.gvwData.FocusedColumn = this.gvwData.Columns["FieldName"]; // FieldName --列名
关闭Popup
PopupContainerCIQNo.OwnerEdit.ClosePopup();
GridView
#region 显示明细行号
/// <summary>
/// 显示明细行号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gvwData_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
if (e.Info.IsRowIndicator)
{
if (e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
}
}
#endregion
#region 禁止 Popup 弹出 如果X>1 禁止Popup 弹出
private void editorGoodsCode_QueryPopUp_1(object sender, CancelEventArgs e)
{
if (x>1)
{
e.Cancel = true;
return;
}
if (sender is PopupContainerEdit)
{
PopupContainerEdit edit = (PopupContainerEdit)sender;
PopupContainerControl control = edit.Properties.PopupControl;
control.Width = 800;
control.Height = 600;
popupInStoreLine1.GoodsOwnerCode = cmbGoodsOwnerCode.EditValue.ToString();
}
}
#endregion
#region 设置 POPUP 大小
private void PopupContainerEdit_QueryPopUp(object sender, System.ComponentModel.CancelEventArgs e)
{
PopupContainerEdit edit = (PopupContainerEdit)sender;
PopupContainerControl control = edit.Properties.PopupControl;
control.Width = 800;
control.Height = 600;
}
#endregion
//分页查询
public static PageInfo GetDataByConditions(string GOCode, string GOName)
{
PageInfo pageInfo = new PageInfo();
pageInfo.RecordCountSQL = @"SELECT COUNT(1) FROM dbo.DataTable
WHERE 1 = 1 ";
pageInfo.RecordSQL = @"SELECT * FROM dbo.DataTable WHERE 1 = 1 ";
string strWhere = string.Empty;
List<object> paraValues = new List<object>();
// 分类代码
if (!String.IsNullOrEmpty(GOCode))
{
strWhere += " AND A.GOCode LIKE @P0";
paraValues.Add("%" + GOCode + "%");
}
// 分类名称
if (!String.IsNullOrEmpty(GOName))
{
strWhere += " AND A.GOName LIKE @P1";
paraValues.Add("%" + GOName + "%");
}
pageInfo.RecordCountSQL = pageInfo.RecordCountSQL + strWhere;
pageInfo.RecordSQL = pageInfo.RecordSQL + strWhere;
pageInfo.Parameters = paraValues;
return pageInfo;
}