public partial class WeighRecord : Form { WeighRecordSet headsSet = null; public WeighRecord() { InitializeComponent(); this.RecordTimepx.Format = DateTimePickerFormat.Custom; this.RecordTimepx.CustomFormat = " "; this.GrossTimepx.Format = DateTimePickerFormat.Custom; this.GrossTimepx.CustomFormat = " "; this.TareTimepx.Format = DateTimePickerFormat.Custom; this.TareTimepx.CustomFormat = " "; //测试数据 //var list = new List(); //list.Add(new WeighRecordDto() { Number = 1 }); //list.Add(new WeighRecordDto() { Number = 2 }); //list.Add(new WeighRecordDto() { Number = 3 }); //list.Add(new WeighRecordDto() { Number = 4 }); //list.Add(new WeighRecordDto() { Number = 5 }); //this.dataGV.DataSource = list; } private void RecordTimepx_ValueChanged(object sender, EventArgs e) { this.RecordTimepx.Format = DateTimePickerFormat.Long; this.RecordTimepx.CustomFormat = null; } private void GrossTimepx_ValueChanged(object sender, EventArgs e) { this.GrossTimepx.Format = DateTimePickerFormat.Long; this.GrossTimepx.CustomFormat = null; } private void TareTimepx_ValueChanged(object sender, EventArgs e) { this.TareTimepx.Format = DateTimePickerFormat.Long; this.TareTimepx.CustomFormat = null; } //查询 private void SearchBtn_Click(object sender, EventArgs e) { } //显示设置 List childList = null; private void ShowSetBtn_Click(object sender, EventArgs e) { //填充值 if (childList == null) { childList = new List(); for (var i = 0; i < this.WeighTable.Columns.Count; i++) { if (this.WeighTable.Columns[i].Visible) { childList.Add(new TableHeader() { Name = this.WeighTable.Columns[i].HeaderText, Choice = this.WeighTable.Columns[i].Visible, }); } } } //传入值 headsSet = new WeighRecordSet(childList); //回传值 headsSet.itemTextChanged += new EventHandler((sender1, e1) => { childList = headsSet.list; //回传值 for (var j = 0; j < headsSet.list.Count; j++) { var item = headsSet.list[j]; for (var i = 0; i < this.WeighTable.Columns.Count; i++) { if (this.WeighTable.Columns[i].HeaderText == item.Name) { this.WeighTable.Columns[i].DisplayIndex = j; this.WeighTable.Columns[i].Visible = item.Choice; break; } } } }); //弹出窗体 headsSet.ShowDialog(); } }
public partial class WeighRecordSet : Form { public List list { get; set; } public event EventHandler itemTextChanged; public WeighRecordSet() { InitializeComponent(); list = new List(); list.Add(new TableHeader() { Name = "序号" }); list.Add(new TableHeader() { Name = "车牌号" }); list.Add(new TableHeader() { Name = "司机" }); list.Add(new TableHeader() { Name = "货品" }); list.Add(new TableHeader() { Name = "毛重" }); list.Add(new TableHeader() { Name = "皮重" }); list.Add(new TableHeader() { Name = "净重" }); list.Add(new TableHeader() { Name = "扣重" }); list.Add(new Tabl.........