Files
cyf ab56a9bcf7 基线 SVN r240
SVN-Revision: r240
2025-02-06 06:46:06 +00:00

209 lines
7.8 KiB
C#

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
{
/// <summary>
/// 自动搜索框弹出框
/// </summary>
public partial class AutoGridPopup : UserControl
{
/// <summary>
/// 是否显示添加按钮
/// </summary>
/// <value><c>true</c> if [add visible]; otherwise, <c>false</c>.</value>
public bool AddVisible
{
get { return this.btnAdd.Visible; }
set
{
this.btnAdd.Visible = value;
this.pl_bottom.Visible = value;
}
}
/// <summary>
/// 输入框
/// </summary>
public AutoGridLookUp LookUp;
/// <summary>
/// Gets the grid control object.
/// </summary>
/// <value>The grid control object.</value>
public GridControl GridControlObj { get { return this.gridControl; } }
/// <summary>
/// Gets the grid view object.
/// </summary>
/// <value>The grid view object.</value>
public GridView GridViewObj { get { return this.gridView; } }
/// <summary>
/// 提示文本
/// </summary>
/// <value>The label object.</value>
public LabelControl LabelObj { get { return this.lbl_title; } }
/// <summary>
/// Gets the top panel object.
/// </summary>
/// <value>The top panel object.</value>
public PanelControl BottomPanelObj { get { return this.pl_bottom; } }
/// <summary>
/// 缓存列对象
/// </summary>
public List<GridColumnModel> ColumnList = new List<GridColumnModel>();
/// <summary>
/// 弹出框回车事件
/// </summary>
public event KeyEventHandler OnGridViewEnter;
/// <summary>
/// 添加按钮点击事件
/// </summary>
public event EventHandler OnAddMouseClick;
/// <summary>
/// 弹出框鼠标点击
/// </summary>
public event EventHandler OnGridViewMouseClick;
/// <summary>
/// The reset colum primary key
/// </summary>
public string CustomColumKey;
public ControlModel Model;
public AutoGridPopup()
{
InitializeComponent();
this.GotFocus += new EventHandler(OnAutoGridPopupGotFocus);
this.gridView.CustomDrawRowIndicator += new RowIndicatorCustomDrawEventHandler(OnGridViewCustomDrawRowIndicator);
this.gridView.CustomDrawCell += new DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(OnGridViewCustomDrawCell);
}
/// <summary>
/// <para>说明:GridView获取焦点</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-03-16 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void OnAutoGridPopupGotFocus(object sender, EventArgs e)
{
if (this.gridView.DataSource != null)
{
this.gridView.FocusedRowHandle = 0;
this.gridView.SelectRow(0);
}
}
/// <summary>
/// <para>说明:生成序号</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-03-15 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowIndicatorCustomDrawEventArgs" /> instance containing the event data.</param>
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)
{
}
}
/// <summary>
/// <para>说明:设置颜色</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-03-16 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs"/> instance containing the event data.</param>
protected void OnGridViewCustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.RowHandle == gridView.FocusedRowHandle)
e.Appearance.BackColor = ColorTranslator.FromHtml("#9feb6a");
}
/// <summary>
/// <para>说明:键盘弹起</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-03-16 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
protected void OnGridViewKeyUp(object sender, KeyEventArgs e)
{
if (this.OnGridViewEnter != null)
this.OnGridViewEnter(this.gridView, e);
}
/// <summary>
/// <para>说明:点击GridView</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-03-16 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
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);
}
/// <summary>
/// <para>说明:添加操作</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-04-03 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void OnAddButtonClick(object sender, EventArgs e)
{
if (this.OnAddMouseClick != null)
this.OnAddMouseClick(sender, e);
}
}
}