using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Lskj.Control; using Lskj.Core; using DevExpress.XtraEditors.Repository; using DevExpress.XtraEditors.Controls; using DevExpress.Utils; using DevExpress.XtraGrid.Views.Grid; namespace Lskj.ToolSetNew { public partial class PreviewFrom : BaseForm { public string sqlFormat = string.Empty; public PreviewFrom() { InitializeComponent(); } #region 初始化预览表格数据 public void iniControls(DataTable dt, string TableName) { InitGridControl(TableName); this.gcMain.DataSource = dt; this.gvMain.CustomDrawRowIndicator += new RowIndicatorCustomDrawEventHandler(OnGridViewCustomDrawRowIndicator); } #endregion #region 序号生成事件 /// /// 说明:生成序号 /// 创建人:王一帆 /// 创建日期:2020-12-31 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. protected virtual 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) { } } #endregion #region 初始化表格控件 /// /// 说明: 初始化表格控件 /// 创建人:王一帆 /// 创建日期:2020-12-31 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. private void InitGridControl(string TableName) { switch (TableName) { case "p_systemwordbooktab": case "p_systemdlltabflowstepgrid": sqlFormat = "select DllCoid as dm,ToolsName as mc from P_systemdllTab"; this.ModelName.FieldName = "tab"; this.userName.FieldName="username1"; this.fieldName.FieldName = "fieldname"; break; case "p_systemDlltabDetailGrid": sqlFormat = "select formkey as dm,detailName as mc from p_systemDlltabDetail"; this.ModelName.FieldName = "detailKey"; break; case "p_systembillDetail": case "p_systembillstepgrid": sqlFormat = "select typeCode as dm,typeName as mc from p_systembilltype"; this.ModelName.FieldName = "typeCode"; break; case "p_systembillsourcegrid": case "p_systembillsourcedetail": sqlFormat = "select formKey as dm,sourceName as mc from p_systembillsource"; this.ModelName.FieldName = "sourcekey"; break; case "p_systembillauditAttachDetail": sqlFormat = "select formKey as dm,attachName as mc from p_systembillauditAttach"; this.ModelName.FieldName = "attachKey"; break; } DataTable ColumnFormat = SqlHelper.ExecuteDataTable(sqlFormat); RepositoryItemLookUpEdit comboxEdit = this.repositoryItemLookUpEdit1; comboxEdit.ShowHeader = false; comboxEdit.ImmediatePopup = false; comboxEdit.SearchMode = SearchMode.AutoFilter; comboxEdit.NullText = ""; comboxEdit.PopupBorderStyle = PopupBorderStyles.Flat; comboxEdit.AllowNullInput = DefaultBoolean.False; comboxEdit.DisplayMember = "mc"; comboxEdit.ValueMember = "dm"; comboxEdit.DataSource = ColumnFormat; LookUpColumnInfo valueColumn = new LookUpColumnInfo(); } #endregion } }