퇴근5분전

# 4) .Net ( Vs 2010 )/DevExpress +3

 

 

 

 

버튼 Edit에 Masking!

 

  if (_edittype == ButtonEditEx_EditType.Tel)
            {
                Properties.Mask.EditMask = @"[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}";
                Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.RegEx;
                Properties.Mask.UseMaskAsDisplayFormat = true;
            }
            else if (_edittype == ButtonEditEx_EditType.Email)
            {
                Properties.Mask.EditMask = @"[a-zA-Z0-9.-]+@[a-zA-Z0-9-]+(\.[A-Za-z]{2,6}){1,2}";
                Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.RegEx;
                Properties.Mask.UseMaskAsDisplayFormat = true;
            }
            else if (_edittype == ButtonEditEx_EditType.Money)
            {
                Properties.Mask.EditMask = GetMoneyMasking();
                Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
                Properties.Mask.UseMaskAsDisplayFormat = true;
            }           

 

 private string GetMoneyMasking()
        {
            string editmask = "N0";
            if (Properties.MaxLength > 0)
            {
                string masking = "";
                for (int loop = 0; loop < Properties.MaxLength; loop++)
                {
                    masking = "#" + masking;
                    if (loop % 3 == 2)
                    {
                        masking = "," + masking;
                    }
                }
                editmask = masking;
            }
            return editmask;
        }

 

Number의 자리수 제한은 maxlength 로 제한 할때 #,###,###으로 표기하기 위해...

 

 

 

'# 4) .Net ( Vs 2010 ) > DevExpress' 카테고리의 다른 글

Grid  (0) 2015.01.25
TreeList  (0) 2015.01.25

 

 

 

private void InitGrid()
        {
            gridView1.OptionsView.ShowGroupPanel = false;

            var col1 = gridView1.Columns.Add();
            col1.FieldName = "Key";
            col1.Caption = "메뉴ID";
            col1.Width = 120;
            col1.Visible = true;

            var col2 = gridView1.Columns.Add();
            col2.FieldName = "Name";
            col2.Caption = "메뉴명";
            col2.Width = 220;
            col2.Visible = true;
            
            gridControl1.DataSource = GetDataSource();
        }

 

음.. 버튼도 넣어볼까나?

 

 

 

 

   private void InitGrid()
        {
            gridView1.OptionsView.ShowGroupPanel = false;

            var col1 = gridView1.Columns.Add();
            col1.FieldName = "Key";
            col1.Caption = "메뉴ID";
            col1.Width = 120;
            col1.Visible = true;

            var col2 = gridView1.Columns.Add();
            col2.FieldName = "Name";
            col2.Caption = "메뉴명";
            col2.Width = 220;
            col2.Visible = true;

               var col3 = gridView1.Columns.Add();
            col3.Caption = "컬럼";
            col3.Width = 150;
            col3.Visible = true;
            var redit = new DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit();
            redit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
            var btnEdit = new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph);
            redit.Buttons.Add(btnEdit);
            redit.Buttons[0].Caption = "001";
          redit.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph;
          redit.Buttons[1].Caption = "002";
          redit.Buttons[1].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph;

            redit.ButtonClick += redit_ButtonClick;
            col3.ColumnEdit = redit;             gridControl1.DataSource = GetDataSource();
        }

        void redit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (e.Button.Index == 0)
            {
                MessageBox.Show(e.Button.Caption);
            }
            else if (e.Button.Index == 1)
            {
                MessageBox.Show(e.Button.Caption);
            }
        }

 

 

 

 

 

 

'# 4) .Net ( Vs 2010 ) > DevExpress' 카테고리의 다른 글

ButtonEdit  (0) 2015.01.25
TreeList  (0) 2015.01.25

 

+ TreeList...  그리고 VGridControl

 

 지금 프로젝트에서 사용하는 사용컨트롤인데...

처음 접하는 프로젝트였으므로 공부를 해볼 시간이 필요했는데, 잘 안되었다...

 

 경험자였던 팀원분은 두달간 메뉴 여섯개 두달간 만드시다 잘렸고...

 

근데 막상 쭉 해보니 별건 아닌데... 왜 두달이 걸렸을까?

추가사항이나 수정사항이 나올때마다 왜 프로그래밍을 이렇게 했을까 싶을 정도로... 생각이 안잡힌다.

 

너무 복잡했던 사용법들때문에 그냥 집에서 사용법들을 알아봤다.

 

private void InitTreeList()
        {
            TreeListColumn tcKey = treeList1.Columns.Add();
            tcKey.FieldName = "Key";
            tcKey.Caption = "메뉴ID";
            tcKey.Visible = true;
            tcKey.VisibleIndex = 2;

            TreeListColumn tcName = treeList1.Columns.Add();
            tcName.FieldName = "Name";
            tcName.Caption = "메뉴명";
            tcName.Visible = true;
            tcName.VisibleIndex = 1;
            treeList1.KeyFieldName = "Key";
            treeList1.ParentFieldName = "Prn_Key";
            treeList1.DataSource = GetDataSource();
        }

 

초간단 바인딩.

 

그러면 트리가 짠!

 

데이타 입력 수정 삭제 처리시 트리에 색상 반영은.

 

private void treeList1_NodeCellStyle(object sender, DevExpress.XtraTreeList.GetCustomNodeCellStyleEventArgs e)
        {
            DataRowView currentNode = treeList1.GetDataRecordByNode(e.Node) as DataRowView;
            if (currentNode != null)
            {
                if (currentNode.Row.RowState == DataRowState.Added)
                {
                    e.Column.AppearanceCell.ForeColor = Color.Blue;
                }
                else if (currentNode.Row.RowState == DataRowState.Modified)
                {
                     e.Column.AppearanceCell.ForeColor = Color.Green;
                }
                else if (currentNode.Row.RowState == DataRowState.Deleted)
                {
                     e.Column.AppearanceCell.ForeColor = Color.Silver;
                }
                else
                {
                     e.Column.AppearanceCell.ForeColor = Color.Black
                }
            }
        }

 

그리고 treeList1.GetDataRecordByNode <-- 요 메서드

바인딩 된 노드의 데이타객체로 변환하는 메서드

 

추가적으로

private void GetChangeDataButton_Click(object sender, EventArgs e)
        {
            StringBuilder query = new StringBuilder();
            var table = treeList1.DataSource as DataTable;
            var chage = table.GetChanges();
            if (chage != null)
            foreach (DataRow dr in chage.Rows)
            {
                if ((dr.RowState & (DataRowState.Modified | DataRowState.Added | DataRowState.Deleted)) > 0)
                {
                    query.AppendFormat("MenuID = {0}, MenuName = {1}" + Environment.NewLine, dr[0], dr[1]);
                }
            }
            MessageBox.Show("" + query);
        }

 

이건 바인딩 된 데이타의 변경된 데이타만을 가져오는 부분.

 

또 여기에 VGridControl 췟!

 

팀원이었던 분이 써놓은 컨트롤인데 ... 이것도 당췌 왜 그렇게 사용했는지 알수가 없는데

사용이 겁나게 단순한데...

 

  private void InitVGrid()
        {
            var keyEdit = new DevExpress.XtraVerticalGrid.Rows.EditorRow("Key");
            keyEdit.Properties.Caption = "메뉴ID";
            keyEdit.Properties.ReadOnly = true;
            vGridControl1.Rows.Add(keyEdit);

            var nameEdit = new DevExpress.XtraVerticalGrid.Rows.EditorRow("Name");
            nameEdit.Properties.Caption = "메뉴명";
            nameEdit.Properties.ReadOnly = false;
            vGridControl1.Rows.Add(nameEdit);
            vGridControl1.DataSource = treeList1.DataSource;
        }

 

요렇게 ㅡ.,ㅡ;; 끝.

그냥 저거 한줄이면 되는데...

 

음... 그분은 왜? 객체를 몇개나 만들어서 줬다 받았다 했을까?

 

 

 

 

 

 

 

 

 

 

'# 4) .Net ( Vs 2010 ) > DevExpress' 카테고리의 다른 글

ButtonEdit  (0) 2015.01.25
Grid  (0) 2015.01.25