示例#1
0
        /// <summary>
        /// 属性窗属性值更改事件
        /// 当是否使用缺省文本属性改变时,保存是否使用缺省文本设置
        /// 当文本属性更改时,更新控件文本属性(因为不会自动更新)
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void propertyGrid1_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
        {
            bool boolOld = false;
            bool boolNew = false;

            //是否使用缺省文本属性
            if (e.ChangedItem.Label == "IsUseDefaultText")
            {
                boolOld = (bool)e.OldValue;
                boolNew = (bool)e.ChangedItem.Value;
            }
            //展开文本属性
            else if (e.ChangedItem.Label == "ControlText")
            {
                ControlText OldText    = (ControlText)e.OldValue;
                ControlText NewText    = (ControlText)e.ChangedItem.Value;
                OwnControl  ownControl = (OwnControl)this.propertyGrid1.SelectedObject;
                ownControl.ControlText = NewText;
                boolOld = OldText.IsUseDefaultText;
                boolNew = NewText.IsUseDefaultText;
            }
            //文本属性
            else if (e.ChangedItem.Label == "Text")
            {
                OwnControl  ownControl = (OwnControl)this.propertyGrid1.SelectedObject;
                ControlText NewText    = new ControlText((string)e.ChangedItem.Value, ownControl.ControlText.IsUseDefaultText);
                ownControl.ControlText = NewText;
            }

            //保存到Xml文件
            if (boolOld != boolNew)
            {
                design.SaveIsUseDefaultTextSetting(this.cboControlList.Text, boolNew);
            }
        }
示例#2
0
        /// <summary>
        /// 更新属性框
        /// </summary>
        /// <param name="control"></param>
        private void UpdateProperty(Control control)
        {
            control.Focus();
            design.DrawControlPoint(control);
            OwnControl ownControl = new OwnControl(design.GetIsUseDefaultTextSetting(control));

            ownControl.Control = control;
            this.propertyGrid1.SelectedObject = ownControl;
        }