using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
namespace Nbjjy.Utilities
{
public partial class CustomColumnDialog : DevExpress.XtraEditors.XtraForm
{
private DataTable dt;
private GridColumnCollection cols;
public CustomColumnDialog(GridColumnCollection cols)
{
InitializeComponent();
this.cols = cols;
this.GridColumn();
this.gridControl1.DataSource = this.dt;
}
private void GridColumn()
{
this.dt = new DataTable();
this.dt.Columns.AddRange(new DataColumn[]
{
new DataColumn("Selected", typeof(bool)),
new DataColumn("Caption", typeof(string))
});
foreach (GridColumn gridColumn in cols)
{
DataRow dataRow = this.dt.NewRow();
dataRow["Selected"] = (gridColumn.VisibleIndex >= 0);
dataRow["Caption"] = gridColumn.Caption;
this.dt.Rows.Add(dataRow);
}
}
private void btnAllSelected_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.dt.Rows.Count; i++)
{
dt.Rows[i]["Selected"] = true;
}
this.gridView1.UpdateCurrentRow();
}
private void btnUnSelected_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.dt.Rows.Count; i++)
{
dt.Rows[i]["Selected"] = false;
}
this.gridView1.UpdateCurrentRow();
}
private void btnResume_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.dt.Rows.Count; i++)
{
dt.Rows[i]["Selected"] = true;
}
this.gridView1.UpdateCurrentRow();
base.DialogResult = DialogResult.Abort;
base.Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
for (int num = 0; num < this.cols.Count; num++)
GridControl 自定义显示列
最新推荐文章于 2022-12-26 20:34:25 发布