using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lskj.Control.Model;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.Utils;
namespace Lskj.Control
{
///
/// 自动搜索框弹出框
///
public partial class AutoGridRevPopup : UserControl
{
///
/// 是否显示添加按钮
///
/// true if [add visible]; otherwise, false.
public bool AddVisible
{
get { return this.btnAdd.Visible; }
set
{
this.btnAdd.Visible = value;
this.pl_bottom.Visible = value;
}
}
///
/// 输入框
///
public AutoGridRevLookUp LookUp;
///
/// Gets the grid control object.
///
/// The grid control object.
public GridControl GridControlObj { get { return this.gridControl; } }
///
/// Gets the grid view object.
///
/// The grid view object.
public GridView GridViewObj { get { return this.gridView; } }
///
/// 提示文本
///
/// The label object.
public LabelControl LabelObj { get { return this.lbl_title; } }
///
/// Gets the top panel object.
///
/// The top panel object.
public PanelControl BottomPanelObj { get { return this.pl_bottom; } }
///
/// 缓存列对象
///
public List ColumnList = new List();
///
/// 弹出框回车事件
///
public event KeyEventHandler OnGridViewEnter;
///
/// 添加按钮点击事件
///
public event EventHandler OnAddMouseClick;
///
/// 弹出框鼠标点击
///
public event EventHandler OnGridViewMouseClick;
///
/// The reset colum primary key
///
public string CustomColumKey;
public ControlModel Model;
public AutoGridRevPopup()
{
InitializeComponent();
this.GotFocus += new EventHandler(OnAutoGridPopupGotFocus);
this.gridView.CustomDrawRowIndicator += new RowIndicatorCustomDrawEventHandler(OnGridViewCustomDrawRowIndicator);
this.gridView.CustomDrawCell += new DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(OnGridViewCustomDrawCell);
}
///
/// 说明:GridView获取焦点
/// 创建人:龚宇超
/// 创建日期:2018-03-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
protected void OnAutoGridPopupGotFocus(object sender, EventArgs e)
{
if (this.gridView.DataSource != null)
{
this.gridView.FocusedRowHandle = 0;
this.gridView.SelectRow(0);
}
}
///
/// 说明:生成序号
/// 创建人:龚宇超
/// 创建日期:2018-03-15
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
protected void OnGridViewCustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
{
try
{
e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
if (e.Info.IsRowIndicator)
{
if (e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
}
}
catch (Exception)
{
}
}
///
/// 说明:设置颜色
/// 创建人:龚宇超
/// 创建日期:2018-03-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
protected void OnGridViewCustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.RowHandle == gridView.FocusedRowHandle)
e.Appearance.BackColor = ColorTranslator.FromHtml("#9feb6a");
}
///
/// 说明:键盘弹起
/// 创建人:龚宇超
/// 创建日期:2018-03-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
protected void OnGridViewKeyUp(object sender, KeyEventArgs e)
{
if (this.OnGridViewEnter != null)
this.OnGridViewEnter(this.gridView, e);
}
///
/// 说明:点击GridView
/// 创建人:龚宇超
/// 创建日期:2018-03-16
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
protected void OnGridViewMouseDown(object sender, MouseEventArgs e)
{
int rowHandle = this.gridView.CalcHitInfo(e.X, e.Y).RowHandle;
this.gridView.FocusedRowHandle = rowHandle;
this.gridView.SelectRow(rowHandle);
if (rowHandle > -1 && this.OnGridViewMouseClick != null)
this.OnGridViewMouseClick(this.gridView, null);
}
///
/// 说明:添加操作
/// 创建人:龚宇超
/// 创建日期:2018-04-03
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
protected void OnAddButtonClick(object sender, EventArgs e)
{
if (this.OnAddMouseClick != null)
this.OnAddMouseClick(sender, e);
}
}
}