using DevExpress.XtraGrid.Views.Grid;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
|
namespace TProduct.WinFrmUI.TValve
|
{
|
public partial class GridFeatCorrectPtCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public GridFeatCorrectPtCtrl()
|
{
|
InitializeComponent();
|
|
this.gridViewMain.OptionsDetail.ShowDetailTabs = false;//不显示TAB名
|
this.gridViewMain.OptionsView.ShowGroupPanel = false;//隐藏最上面的GroupPanel
|
this.gridViewMain.OptionsSelection.MultiSelect = false;//单选
|
this.gridViewMain.OptionsBehavior.Editable = false;//只读
|
this.gridViewMain.BestFitColumns();
|
this.gridViewMain.IndicatorWidth = 20;
|
|
|
this.gridViewMain.OptionsView.EnableAppearanceEvenRow = true;
|
this.gridViewMain.OptionsView.EnableAppearanceOddRow = true;
|
|
this.gridViewMain.RowClick += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(this.GridViewMain_RowClick);
|
this.gridViewMain.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.GridViewMain_CustomDrawRowIndicator);
|
this.gridViewMain.CustomUnboundColumnData += new DevExpress.XtraGrid.Views.Base.CustomColumnDataEventHandler(this.GridViewMain_CustomUnboundColumnData);
|
//this.gridViewMain.DoubleClick += new System.EventHandler(this.GridViewMain_DoubleClick);
|
this.gridViewMain.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(this.GridViewMain_RowCellClick);
|
this.gridViewMain.OptionsView.EnableAppearanceOddRow = true; // 使能 // 和和上面绑定 同时使用有效
|
this.gridViewMain.Appearance.EvenRow.BackColor = Color.LightGray; // 设置偶数行颜色
|
}
|
|
//刷新数据源
|
public bool RefreshData(List<TProduct.Model.ValveFeatTestRecordViewModel> allRecords)
|
{
|
this.bindingSource1.DataSource = allRecords;
|
this.bindingSource1.ResetBindings(false);
|
return true;
|
}
|
public bool ClearData()
|
{
|
this.bindingSource1.DataSource = null;
|
this.bindingSource1.ResetBindings(false);
|
return true;
|
}
|
#region GridViewMain
|
// TProduct.Model.ValveFeatTestRecordViewModel _clickProjectRow = null;
|
private void GridViewMain_RowClick(object sender, RowClickEventArgs e)
|
{
|
if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
{
|
// _clickProjectRow = gridViewMain.GetRow(e.RowHandle) as TProduct.Model.ValveFeatTestRecordViewModel;
|
//_rightClickProject = (gridViewMain.GetRow(e.RowHandle) as System.Data.DataRowView).Row as TProduct.WinFrmUI.Sale.DataSetUI.SaleProjectRow;
|
// _rightClickProject = gridViewMain.GetFocusedDataRow() as TProduct.WinFrmUI.Sale.DataSetUI.SaleProjectRow;
|
//if (_clickProjectRow != null)
|
//{
|
// if (_clickProjectRow.ProjectStyle == 1)
|
// { //简易项目
|
// MenuItem转为简易项目.Visible = false;
|
// }
|
// else
|
// {
|
// MenuItem转为简易项目.Visible = true ;
|
// }
|
|
// GidViewMenuStrip.Show(gridControl1, e.Location);
|
//}
|
}
|
}
|
|
//
|
private void GridViewMain_DoubleClick(object sender, EventArgs e)
|
{
|
//var view = sender as GridView;
|
//if (view != null)
|
//{
|
// var point = view.GridControl.PointToClient(MousePosition);
|
// var pumpStr = view.CalcHitInfo(point);
|
// if (pumpStr.InRow || pumpStr.InRowCell)
|
// {
|
// // _clickPrjItem = gridViewAttach.GetRow(pumpStr.RowHandle) as MotorInfoExCatalogName;
|
// //// _clickPrjItem = (gridViewAttach.GetRow(pumpStr.RowHandle) as System.Data.DataRowView).Row as DAL.DataSetCustomer.CustomerVipInfoRow;
|
// // if (_clickPrjItem != null)
|
// // {
|
// // if (_clickPrjItem.RecordGID == Guid.Empty)
|
// // return;
|
// // }
|
// }
|
//}
|
}
|
public Action<TProduct.Model.ValveFeatTestRecordViewModel> OnEditRecord = null;
|
public Action<TProduct.Model.ValveFeatTestRecordViewModel> OnDeleteRecord = null;
|
|
private void GridViewMain_RowCellClick(object sender, RowCellClickEventArgs e)
|
{
|
if (e.Column == colDelete)
|
{
|
var prjEntity =
|
this.gridViewMain.GetRow(e.RowHandle) as TProduct.Model.ValveFeatTestRecordViewModel;
|
|
OnDeleteRecord(prjEntity);
|
}
|
if (e.Column == colEdit)
|
{
|
var prjEntity =
|
this.gridViewMain.GetRow(e.RowHandle) as TProduct.Model.ValveFeatTestRecordViewModel;
|
|
OnEditRecord(prjEntity);
|
}
|
}
|
|
|
private void GridViewMain_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
|
{
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
{
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
}
|
}
|
|
private void GridViewMain_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
|
{
|
//if (e.Column == colCreateTime)
|
//{
|
// var prj = e.Row as TProduct.Model.SaleProject;
|
// if (prj == null)
|
// return;
|
|
// e.Value = prj.GetCreateTime();
|
//}
|
|
|
}
|
#endregion
|
|
}
|
}
|