CSFramework开发框架支持表格编辑窗体,批量修改表格的数据
CSFramework开发框架支持表格编辑窗体,批量修改表格的数据
扫一扫加微信
表格编辑窗体例子: frmPersonGrid
表格编辑窗体的代码非常少:
C# Code:
/// <summary>
/// 支持表格编辑窗体,批量修改数据窗体保存数据
/// </summary>
public partial class frmPersonGrid : frmBaseGridEditForm
{
public frmPersonGrid()
{
InitializeComponent();
}
private void frmPersonGrid_Load(object sender, EventArgs e)
{
_BLL = new bllPerson();
_SummaryView = new DevGridView(gvSummary);//每个业务窗体必需给这个变量赋值.
this.InitButtons();
this.HandlePKColumn(gvSummary);
gcSummary.DataSource = _BLL.GetSummaryData(true);//显示所有数据
DevStyle.SetGridControlLayout(gcSummary, true, true, false, true);//表格设置
gcSummary.EmbeddedNavigator.ButtonClick += new NavigatorButtonClickEventHandler(this.OnEmbeddedNavigatorButtonClick); //表格按钮事件
}
/// <summary>
/// 明细表格内按钮的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnEmbeddedNavigatorButtonClick(object sender, NavigatorButtonClickEventArgs e)
{
try
{
GridControl gc = (GridControl)((GridControlNavigator)sender).Parent;
GridView gridView = (GridView)gc.Views[0]; //每个GridControl只有一个GridView.
if (e.Button.ImageIndex == (int)DetailButtons.Add)
{
gridView.AddNewRow();
}
else if (e.Button.ImageIndex == (int)DetailButtons.Delete)
{
if (Msg.AskQuestion("真的要删除这条记录?"))
gridView.DeleteRow(gridView.FocusedRowHandle);
}
e.Handled = true;
}
catch (Exception ex)
{
LogUserOperate.Write(ex);
Msg.ShowException(ex);
}
}
private void btnFind_Click(object sender, EventArgs e)
{
//查询数据
DataTable dt = (_BLL as bllPerson).GetSummaryData(txt_Name.Text);
gcSummary.DataSource = dt;
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
/// 支持表格编辑窗体,批量修改数据窗体保存数据
/// </summary>
public partial class frmPersonGrid : frmBaseGridEditForm
{
public frmPersonGrid()
{
InitializeComponent();
}
private void frmPersonGrid_Load(object sender, EventArgs e)
{
_BLL = new bllPerson();
_SummaryView = new DevGridView(gvSummary);//每个业务窗体必需给这个变量赋值.
this.InitButtons();
this.HandlePKColumn(gvSummary);
gcSummary.DataSource = _BLL.GetSummaryData(true);//显示所有数据
DevStyle.SetGridControlLayout(gcSummary, true, true, false, true);//表格设置
gcSummary.EmbeddedNavigator.ButtonClick += new NavigatorButtonClickEventHandler(this.OnEmbeddedNavigatorButtonClick); //表格按钮事件
}
/// <summary>
/// 明细表格内按钮的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnEmbeddedNavigatorButtonClick(object sender, NavigatorButtonClickEventArgs e)
{
try
{
GridControl gc = (GridControl)((GridControlNavigator)sender).Parent;
GridView gridView = (GridView)gc.Views[0]; //每个GridControl只有一个GridView.
if (e.Button.ImageIndex == (int)DetailButtons.Add)
{
gridView.AddNewRow();
}
else if (e.Button.ImageIndex == (int)DetailButtons.Delete)
{
if (Msg.AskQuestion("真的要删除这条记录?"))
gridView.DeleteRow(gridView.FocusedRowHandle);
}
e.Handled = true;
}
catch (Exception ex)
{
LogUserOperate.Write(ex);
Msg.ShowException(ex);
}
}
private void btnFind_Click(object sender, EventArgs e)
{
//查询数据
DataTable dt = (_BLL as bllPerson).GetSummaryData(txt_Name.Text);
gcSummary.DataSource = dt;
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
继承表格编辑基类窗体 frmBaseGridEditForm
扫一扫加微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网