コード例 #1
0
        //ReadOnly
        public void SetReadOnly_ByFldName ( string strFldName, bool bReadOnly )
        {
            //如果定义了只能只读, 则程序也不能设置为可读。
            if (IfCanReadOnly_ByFld(strFldName))
                bReadOnly = true;

            int nRow = GetRow_ByFld ( strFldName );
            if ( nRow < 0 )
                return ;

            nColDef = GetColNo_ByName ( "Def" );

            EDITITEMDEF struDef = new EDITITEMDEF ();

            try
            {
                struDef.strComBin = Rows [ nRow ].Cells [ nColDef ].Value.ToString ();
            }
            catch ( Exception ex )
            {
                return;
            }

            struDef.bReadOnly = bReadOnly;

            Rows[nRow].Cells[nColDef].Value = struDef.strComBin;
        }
コード例 #2
0
        public bool IfCanReadOnly_ByFld(string strFldName)
        {
            int nRow = GetRow_ByFld(strFldName);
            if ( nRow < 0 )
                return false;

            nColDef = GetColNo_ByName("Def");

            EDITITEMDEF struDef = new EDITITEMDEF();

            try
            {
                struDef.strComBin = Rows[nRow].Cells[nColDef].Value.ToString();
            }
            catch (Exception ex)
            {
                return false;
            }

            return struDef.bCanReadOnly;
        }
コード例 #3
0
        void SetValue ()
        {
            //FF.Ctrl.MsgBox.Show("000");

            if ( CurrentCell == null )
                return;

            string strValue = CurrentCell.Value.ToString();

            HideAllCtrl();

            int nRow = CurrentCell.RowIndex;
            int nCol = CurrentCell.ColumnIndex;

            EDITITEMDEF struDef = new EDITITEMDEF();

            //FF.Ctrl.MsgBox.Show("111");

            try
            {
                struDef.strComBin = Rows[nRow].Cells[nColDef].Value.ToString();
            }
            catch ( Exception ex )
            {
                return;
            }

            //FF.Ctrl.MsgBox.Show("222");

            if ( struDef.bReadOnly )
                return;

            //test 1234
            //FF.Ctrl.MsgBox.Show(struDef.bEvent.ToString());

            //点击触发父窗口事件。
            if ( struDef.bEvent )
            {
                if ( SendMsg != null )
                {
                    string strCaption = Rows [ nRow ].Cells [ nColCaption ].Value.ToString ();
                    SendMsg(EVENTTYPE.Click, nRow , nCol, strCaption, "");
                }

                EndEdit();
                return;
            }

            //只有点击在第二列(数值列)才有效。
            if ( nCol != nColValue )
                return;

            Rectangle R = GetCellDisplayRectangle ( CurrentCell.ColumnIndex, CurrentCell.RowIndex, false );  //获取单元格位置
            nOldCtrlRow = nRow;
            nOldCtrlCol = nCol;

            if ( struDef.CtrlType == CONTROLTYPE.TextBox )
            {
                if ( txtBox == null )
                    return;

                txtBox.Text = ( CurrentCell == null ) ? "" : strValue;  //对txtBox赋值
                txtBox.SetBounds ( R.X, R.Y, R.Width, R.Height ); //定位坐标位置
                txtBox.Visible = true;

                //test
                //CurrentCell = this[ 0, 0 ];  
                //BeginEdit ( false );
            }

            else if ( struDef.CtrlType == CONTROLTYPE.Combox )
            {
                if ( cmb == null )
                    return;

                FF.Ctrl.Combo.Ary2Combo ( cmb, struDef.aryCombox );

                cmb.Text = ( CurrentCell == null ) ? "" : strValue;  //对combobox赋值
                cmb.SetBounds ( R.X, R.Y, R.Width, R.Height ); //定位坐标位置
                cmb.Visible = true;
            }

            else if ( struDef.CtrlType == CONTROLTYPE.DatePicker ) 
            {
                if ( datPicker == null )
                    return;

                datPicker.strDate = ( CurrentCell == null || strValue == "" ) ? "" : strValue;  //对combobox赋值
                datPicker.SetBounds ( R.X, R.Y, R.Width, R.Height ); //定位坐标位置
                if ( datPicker.strDate.Trim() == "" )
                    datPicker.ShowTxt ();
                else
                    datPicker.ShowDatPacker ();
                datPicker.Visible = true;
            }

        }
コード例 #4
0
        /// <summary>
        /// 防止Fld重名, 用 EDITITEMDEF.Table 再区分一下。
        /// </summary>
        /// <param name="strFld"></param>
        /// <param name="strTab"></param>
        /// <returns></returns>
        public int GetRow_ByFldTab ( string strFld , string strTab )
        {
            EDITITEMDEF struDef = new EDITITEMDEF ();
            nColDef = GetColNo_ByName ( "Def" );

            for ( int i = 0 ; i < Rows.Count ; i++ )
            {
                struDef.strComBin = Rows [ i ].Cells [ nColDef ].Value.ToString ();

                if ( struDef.Fld == strFld && struDef.Table == strTab )
                    return i;
            }

            return -1;
        }
コード例 #5
0
        public static int Compare ( DATA t1, DATA t2 )
        {
            EDITITEMDEF def1 = new EDITITEMDEF();
            EDITITEMDEF def2 = new EDITITEMDEF();
            
            def1.strComBin = t1.Def;
            def2.strComBin = t2.Def;


            if ( def1.OrderNo > def2.OrderNo )
                return 1;
            else if ( def1.OrderNo < def2.OrderNo )
                return -1;

            return 0;
        }
コード例 #6
0
        void SetList ()
        {
            RowTemplate.Height = _nLineH;

            nColCaption = GetColNo_ByName ( "Caption" );
            nColValue = GetColNo_ByName ( "Value" );
            nColDef = GetColNo_ByName ( "Def" );

            if (DataSource == null)
                return;

            if (((System.Windows.Forms.Control) (this)).BindingContext == null)
                return;

            if ( DataSource != null )
                BindingContext [ DataSource ].SuspendBinding ();

            EDITITEMDEF struDef = new EDITITEMDEF();

            for (int i = Rows.Count -1 ; i >= 0 ; i -- )
            {
                struDef.Set_ByCombin ( Rows[i].Cells[nColDef].Value.ToString() );

                if (struDef.bReadOnly)
                {
                    Rows[i].Cells[nColValue].Style.ForeColor = struDef.clrFore;
                    Rows[i].Cells[nColValue].Style.BackColor = clrReadOnly;
                }
                else
                {
                    Rows[i].Cells[nColValue].Style.ForeColor = struDef.clrFore;
                    Rows[i].Cells[nColValue].Style.BackColor = struDef.clrBK;
                }

                if (struDef.bShow)
                {
                    if (_bBrief && struDef.bHideInBrief)
                        Rows[i].Visible = false;
                    else
                        Rows[i].Visible = true;
                }
                else
                    Rows[i].Visible = false;
            }

            if ( DataSource != null )
                BindingContext [ DataSource ].ResumeBinding ();
        }
        void SetValCellColor( ListViewItem li, EDITITEMDEF Def )
        {
            li.UseItemStyleForSubItems = false;

            ListViewItem.ListViewSubItem subItem = li.SubItems[_nColVal];

            SetCellColor( subItem, Def.clrFore, Def.clrBK );

            //只读Item使用特殊颜色标示底色
            //if ( Def.bCanReadOnly )
            if ( ! AllowEdit(Def) )
                SetCellColor( subItem, Def.clrFore, clrReadOnly );
        }
 private bool AllowEdit( EDITITEMDEF Def )
 {
     return (! Def.bCanReadOnly) && (! Def.bReadOnly);
 }
 private bool AllowShow(EDITITEMDEF Def)
 {
     return Def.bCanShow && Def.bShow;
 }
        private EDITITEMDEF GetItemDef( ListViewItem Item )
        {
            EDITITEMDEF ItemDef = new EDITITEMDEF();

            if (Item != null)
                ItemDef = GetItemDef( Item.Tag as DATA );

            return ItemDef;
        }
        protected EDITITEMDEF GetItemDef( DATA data )
        {
            EDITITEMDEF ItemDef = new EDITITEMDEF();
            
            ItemDef.Set_ByCombin( data.Def );

            return ItemDef;
        }