150 lines
5.2 KiB
C#
150 lines
5.2 KiB
C#
using Lskj.Core;
|
|
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;
|
|
|
|
namespace Lskj.Control.SiftColControl
|
|
{
|
|
public partial class FrmGridSiftProjectManager : BaseForm
|
|
{
|
|
public FrmGridSiftProjectManager()
|
|
{
|
|
InitializeComponent();
|
|
this.Load += new EventHandler(OnFrmGridSiftProjectManager_Load);
|
|
}
|
|
/// <summary>
|
|
/// 初始化时
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnFrmGridSiftProjectManager_Load(object sender, EventArgs e)
|
|
{
|
|
InitGrid();
|
|
BindCustomDrawRowIndicator(this.mainGridView);
|
|
InitGridData();
|
|
}
|
|
/// <summary>
|
|
/// 初始化表格
|
|
/// </summary>
|
|
private void InitGrid()
|
|
{
|
|
string sqlStr = "select employeeid,employeename from p_employeetab";
|
|
DataTable sourceTab = SqlHelper.ExecuteDataTable(sqlStr);
|
|
this.operatorGridLookUpEdit.DisplayMember = "employeename";
|
|
this.operatorGridLookUpEdit.ValueMember = "employeeid";
|
|
this.operatorGridLookUpEdit.ShowFooter = false;
|
|
this.operatorGridLookUpEdit.DataSource = sourceTab;
|
|
this.mainGridView.OptionsView.ColumnAutoWidth = true;
|
|
}
|
|
private void InitGridData()
|
|
{
|
|
string sqlStr = @"select name from p_SysModuleSchemeTab where moduleId = '{0}' and operatorid = '{1}' and isPub = '0'
|
|
union all select name from p_SysModuleSchemeTab where moduleId = '{0}' and isPub = '1'";
|
|
DataTable sourceTab = SqlHelper.ExecuteDataTable(string.Format(sqlStr, "", ""));
|
|
this.mainGridControl.DataSource = sourceTab;
|
|
}
|
|
/// <summary>
|
|
/// 新增方案
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void addBtn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// 删除方案
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void deleteBtn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// 保存方案
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void saveBtn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
#region 显示行号
|
|
/// <summary>
|
|
/// <para>说明:显示行号</para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="gridColumn">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
public static void BindCustomDrawRowIndicator(DevExpress.XtraGrid.Views.Grid.GridView view)
|
|
{
|
|
view.IndicatorWidth = CalcIndicatorDefaultWidth(view);
|
|
view.CustomDrawRowIndicator += (s, e) =>
|
|
{
|
|
if (e.RowHandle >= 0)
|
|
{
|
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
}
|
|
};
|
|
view.TopRowChanged += (s, e) =>
|
|
{
|
|
int width = CalcIndicatorBestWidth(view);
|
|
if ((view.IndicatorWidth - 4 < width || view.IndicatorWidth + 4 > width) && view.IndicatorWidth != width)
|
|
{
|
|
view.IndicatorWidth = width;
|
|
}
|
|
};
|
|
}
|
|
/// <summary>
|
|
/// 计算行头宽度
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <returns></returns>
|
|
static int CalcIndicatorBestWidth(DevExpress.XtraGrid.Views.Grid.GridView view)
|
|
{
|
|
int count = view.TopRowIndex + ((DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo)view.GetViewInfo()).RowsInfo.Count;
|
|
if (count == 0)
|
|
{
|
|
count = 30;
|
|
}
|
|
int textWidth = TextRenderer.MeasureText(
|
|
count.ToString(),
|
|
view.Appearance.Row.Font,
|
|
Size.Empty,
|
|
TextFormatFlags.NoPadding | TextFormatFlags.SingleLine).Width;
|
|
return textWidth + 20;
|
|
}
|
|
/// <summary>
|
|
/// 计算默认的宽度
|
|
/// </summary>
|
|
/// <param name="view"></param>
|
|
/// <returns></returns>
|
|
static int CalcIndicatorDefaultWidth(DevExpress.XtraGrid.Views.Grid.GridView view)
|
|
{
|
|
var grid = view.GridControl;
|
|
int rowHeight = 22;//22是Row的估计高度
|
|
if (view.RowHeight > 0)
|
|
{
|
|
rowHeight = view.RowHeight;
|
|
}
|
|
int count = grid != null ? grid.Height / rowHeight : 30;
|
|
int textWidth = TextRenderer.MeasureText(
|
|
count.ToString(),
|
|
view.Appearance.Row.Font,
|
|
Size.Empty,
|
|
TextFormatFlags.NoPadding | TextFormatFlags.SingleLine).Width;
|
|
return textWidth + 20;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|