LayoutControl 佈局控件

          <strong> //LayoutControlItem</strong> 
            //顯示或隱藏
            this.layoutControlItem1.ContentVisible = true;
            //顯示模式 一般、自定義
            this.layoutControlItem1.TextAlignMode = TextAlignModeItem.CustomSize;
            //文本顯示位置  居左
            this.layoutControlItem1.TextLocation = DevExpress.Utils.Locations.Left;
            //文本 間距
            this.layoutControlItem1.TextToControlDistance = 0;
            //文本 寬和高 (可以在屬性中修改)
            //this.layoutControlItem1.TextSize.Width = 45;


          <strong>  //LayoutControlGroup</strong> 
            //是否顯示組標題
            this.layoutControlGroup2.TextVisible = false;
            //是否顯示 展開按鈕
            this.layoutControlGroup3.ExpandButtonVisible = true;
            //展開按鈕的模式  
            this.layoutControlGroup3.ExpandButtonMode = DevExpress.Utils.Controls.ExpandButtonMode.Inverted;
            //展開按鈕顯示在 標題行 尾
            this.layoutControlGroup3.ExpandButtonLocation = DevExpress.Utils.GroupElementLocation.AfterText;
            //是否展開
            this.layoutControlGroup3.Expanded = true;
         /// <summary>
        /// 設置LayoutControl 下的控件不可用(只讀)
        /// </summary>
        /// <param name="isRead">是否只讀 是=true</param>
        private void SetControlReadOnly(bool isRead) {
            //遍歷LayoutControlGroup
            foreach (LayoutControlGroup group in layoutControl1.Items)
            {
                //遍歷LayoutControlItem
                foreach (BaseLayoutItem lci in group.Items) {
                    LayoutControlItem ctl = lci as LayoutControlItem;
                    //判斷不爲空
                    if (!object.Equals(null, ctl))
                    {
                        //控件類型
                        if (ctl.Control is BaseEdit)
                        {
                            BaseEdit be = ctl.Control as BaseEdit;
                            be.Properties.ReadOnly = isRead;
                            be.Enabled = !isRead;
                        }

                        if (ctl.Control is BaseButton) {
                            BaseButton btn = ctl.Control as BaseButton;
                            btn.Enabled = !isRead;
                        }
                    }
                }
            }
        
        }



 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章