private int GetInt( C1NumericEdit ne) { if (ne.Value == null || ne.Value is DBNull) { return(0); } return((int)Utils.AsNumber(ne.Value)); }
/// <summary> /// 数値範囲指定を設定 /// </summary> /// <param name="lo"></param> /// <param name="vo"></param> /// <param name="wo"></param> /// <param name="itemY"></param> /// <param name="r"></param> /// <returns></returns> protected int SetCtlTypeNumericRange(int lo, int vo, int wo, int itemY, DataRow r) { //ラベル SetLabel(lo, itemY, _labelSize, BorderStyle.FixedSingle, r[CommonConsts.db_name].ToString() + "Label", r[CommonConsts.col_name].ToString()); //自 C1NumericEdit ne1 = new C1NumericEdit(); this.MainPanel.Controls.Add(ne1); ne1.ErrorInfo.ErrorAction = ErrorActionEnum.ResetValue; ne1.ErrorInfo.ErrorMessageCaption = _mlu.GetMsg(CommonConsts.TITLE_ERROR); ne1.ErrorInfo.ErrorMessage = _mlu.GetMsg(CommonConsts.MSG_OUT_OF_BOUND); ne1.Location = new Point(vo, itemY); ne1.Name = r[CommonConsts.db_name].ToString() + "_1"; ne1.Size = _ctlSize; ne1.EmptyAsNull = true; ne1.ShowFocusRectangle = true; ne1.TextAlign = HorizontalAlignment.Right; ne1.PostValidation.Intervals.Add(_int32ValueInterval); ne1.MaxLength = CommonConsts.C1NumericEditMaxLength; ne1.ImeMode = ImeMode.Disable; SetLabel(wo, itemY, _waveSize, BorderStyle.None, r[CommonConsts.db_name].ToString() + "RLabel", "~"); itemY += RowHeight; //至 C1NumericEdit ne2 = new C1NumericEdit(); this.MainPanel.Controls.Add(ne2); ne2.ErrorInfo.ErrorAction = ErrorActionEnum.ResetValue; ne2.ErrorInfo.ErrorMessageCaption = _mlu.GetMsg(CommonConsts.TITLE_ERROR); ne2.ErrorInfo.ErrorMessage = _mlu.GetMsg(CommonConsts.MSG_OUT_OF_BOUND); ne2.Location = new Point(vo, itemY); ne2.Name = r[CommonConsts.db_name].ToString() + "_2"; ne2.Size = _ctlSize; ne2.EmptyAsNull = true; ne2.ShowFocusRectangle = true; ne2.TextAlign = HorizontalAlignment.Right; ne2.PostValidation.Intervals.Add(_int32ValueInterval); ne2.MaxLength = CommonConsts.C1NumericEditMaxLength; ne2.ImeMode = ImeMode.Disable; //値設定 ne1.Value = r[CommonConsts.value1].ToString(); ne2.Value = r[CommonConsts.value2].ToString(); return(itemY); }
/// <summary> /// コントロール配置 /// </summary> private void LoadControl() { try { //高さ this.HeightNum.ErrorInfo.ErrorMessageCaption = _mlu.GetMsg(CommonConsts.TITLE_ERROR); this.HeightNum.ErrorInfo.ErrorMessage = _mlu.GetMsg(CommonConsts.MSG_OUT_OF_BOUND); this.HeightNum.Value = ColConfUtil.ColConf.Height; this.HeightNum.PostValidation.Intervals.Add(_viZeroToIntMax); this.HeightNum.MaxLength = CommonConsts.C1NumericEditMaxLength; //列固定 this.FixedNum.ErrorInfo.ErrorMessageCaption = _mlu.GetMsg(CommonConsts.TITLE_ERROR); this.FixedNum.ErrorInfo.ErrorMessage = _mlu.GetMsg(CommonConsts.MSG_OUT_OF_BOUND); this.FixedNum.Value = ColConfUtil.ColConf.LeftFixedCount; this.FixedNum.PostValidation.Intervals.Add(_viZeroToIntMax); this.FixedNum.MaxLength = CommonConsts.C1NumericEditMaxLength; //パネルにコントロールを設定 var query = from ci in ColConfUtil.ColConf.ColList orderby ci.DisplayOrder select ci; int itemY = 5; foreach (ColumnInfo ci in query) { //順序 C1NumericEdit nedo = new C1NumericEdit(); this.ConfigPanel.Controls.Add(nedo); nedo.ErrorInfo.ErrorAction = ErrorActionEnum.ResetValue; nedo.ErrorInfo.ErrorMessageCaption = _mlu.GetMsg(CommonConsts.TITLE_ERROR); nedo.ErrorInfo.ErrorMessage = _mlu.GetMsg(CommonConsts.MSG_OUT_OF_BOUND); nedo.Location = new Point(DispOrderOffset, itemY); nedo.Name = ci.DBName + "DispOrder"; nedo.Size = _dispOrderSize; nedo.VisibleButtons = DropDownControlButtonFlags.None; nedo.TextAlign = HorizontalAlignment.Right; nedo.ShowFocusRectangle = true; //HACK ※これを有効にすると、何故か編集時にExceptionが発生する。 //nedo.PostValidation.Intervals.Add(AppObject.Int32ValueInterval); nedo.MaxLength = CommonConsts.C1NumericEditMaxLength; if (ci.ConfEditable) { nedo.Value = ci.DisplayOrder; } //表示 CheckBox visibleCheck = new CheckBox(); this.ConfigPanel.Controls.Add(visibleCheck); visibleCheck.Location = new Point(VisibleOffset, itemY); visibleCheck.Name = ci.DBName + "Visible"; visibleCheck.Size = _visibleSize; visibleCheck.Checked = ci.Visible; //列名 SetLabel(ColNameOffset, itemY, _colNameSize, ci.DBName + "Col", ci.ColName); //列幅 C1NumericEdit widthNum = new C1NumericEdit(); this.ConfigPanel.Controls.Add(widthNum); widthNum.ErrorInfo.ErrorAction = ErrorActionEnum.ResetValue; widthNum.ErrorInfo.ErrorMessageCaption = _mlu.GetMsg(CommonConsts.TITLE_ERROR); widthNum.ErrorInfo.ErrorMessage = _mlu.GetMsg(CommonConsts.MSG_OUT_OF_BOUND); widthNum.Location = new Point(WidthOffset, itemY); widthNum.Name = ci.DBName + "Width"; widthNum.Size = _dispOrderSize; widthNum.VisibleButtons = DropDownControlButtonFlags.None; widthNum.TextAlign = HorizontalAlignment.Right; widthNum.FormatType = FormatTypeEnum.Integer; widthNum.DataType = typeof(int); widthNum.ShowFocusRectangle = true; widthNum.Value = ci.Width; widthNum.PostValidation.Intervals.Add(_viZeroToIntMax); widthNum.CharCategory = CharCategory.Number; widthNum.MaxLength = CommonConsts.C1NumericEditMaxLength; //備考 SetLabel(NoteOffset, itemY, _noteSize, ci.DBName + "Note", ci.Note); //物理名 SetLabel(DBNameOffset, itemY, _dbNameSize, ci.DBName + "DBName", ci.DBName); if (!ci.ConfEditable) { nedo.ReadOnly = true; visibleCheck.Enabled = false; } itemY += RowOffset; } } finally { } }