/// <summary> /// 设置属性框的值 /// </summary> /// <param name="ent"></param> void SetPropertyGridEnt(DepartmentParameter ent) { if (ent == null) { return; } _srcEnt = ent.DeepClone(); //设置属性窗口的显示值 _departmentName.Value = ent.Name; _departmentName.ReadOnly = false; _departmentEmail.ReadOnly = false; _departmentTel.ReadOnly = false; _departmentStaff.ReadOnly = false; _remarks.ReadOnly = false; _departmentTel.Value = ent.Tel; _departmentEmail.Value = ent.Email; _departmentStaff.Value = ent.Staff; _remarks.Value = ent.Remark; int preCnt = _paramProp.Count; for (int i = 0; i < preCnt; i++) { _props.Remove(_paramProp[i]); } _paramProp.Clear(); propertyGrid.SelectedObject = _props; }
/// <summary> /// farpoint选择单元格变化时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void fpDepartmentInfo_SelectionChanged(object sender, FarPoint.Win.Spread.SelectionChangedEventArgs e) { //获取当前行索引 int n = this._fpDepartmentInfo.ActiveSheet.ActiveCell.Row.Index; //当选择空行时,属性框为空 if (CurrentUser.CurLoginUserInfo.Permission != Permission.普通用户.ToString()) { propertyGrid.Enabled = this._fpDepartmentInfo.ActiveSheet.Cells[n, 1].Value == null ? false : true; } //若无数据则返回 if (n < 2) { return; } //部门名称 string name = ""; //部门电话 string tel = ""; //部门邮箱 string email = ""; //部门人数 string staff = ""; //备注 string remark = ""; //从FarPoint上取值,检查值是否为空 if (this._fpDepartmentInfo.ActiveSheet.Cells[n, 1].Value != null) { name = this._fpDepartmentInfo.ActiveSheet.Cells[n, 1].Value.ToString(); } if (this._fpDepartmentInfo.ActiveSheet.Cells[n, 2].Value != null) { tel = this._fpDepartmentInfo.ActiveSheet.Cells[n, 2].Value.ToString(); } if (this._fpDepartmentInfo.ActiveSheet.Cells[n, 3].Value != null) { email = this._fpDepartmentInfo.ActiveSheet.Cells[n, 3].Value.ToString(); } if (this._fpDepartmentInfo.ActiveSheet.Cells[n, 4].Value != null) { staff = this._fpDepartmentInfo.ActiveSheet.Cells[n, 4].Value.ToString(); } if (this._fpDepartmentInfo.ActiveSheet.Cells[n, 5].Value != null) { remark = this._fpDepartmentInfo.ActiveSheet.Cells[n, 5].Value.ToString(); } //设置属性框的显示值 DepartmentParameter dp = new DepartmentParameter(name, tel, email, staff, remark); //将值显示在属性窗口中 SetPropertyGridEnt(dp); }
/// <summary> /// 深度克隆 /// </summary> /// <returns></returns> public DepartmentParameter DeepClone() { DepartmentParameter cpyEnt = new DepartmentParameter(); cpyEnt.Name = Name; cpyEnt.Tel = Tel; cpyEnt.Email = Email; cpyEnt.Staff = Staff; cpyEnt.Remark = Remark; return(cpyEnt); }