コード例 #1
0
 //绘制选中的单元格,暂时有个背景颜色意思意思
 private void TreeGrid_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
 {
     if (this.SelectMode == SelectModeEnum.Marquee)
     {
         if (AllSelect)//全选,呵呵
         {
             e.Graphics.FillRectangle(new SolidBrush(SelectBackColor), new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Right - e.Bounds.Left, e.Bounds.Bottom - e.Bounds.Top));
         }
         else
         {
             #region
             try
             {
                 if (//这两个条件都视为选中//当选中的很多的时候,感觉很慢
                     (table.Rows.Contains(new object[] { e.Node.Id, e.Column.VisibleIndex }))
                     ||
                     (tempTable.Rows.Contains(new object[] { e.Node.Id, e.Column.VisibleIndex }))
                     )
                 {
                     e.Graphics.FillRectangle(new SolidBrush(SelectBackColor), new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Right - e.Bounds.Left, e.Bounds.Bottom - e.Bounds.Top));
                 }
                 else
                 {
                     e.Graphics.FillRectangle(new SolidBrush(Color.Transparent), new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Right - e.Bounds.Left, e.Bounds.Bottom - e.Bounds.Top));
                 }
                 if (e.Focused)//跟Excel一样,给焦点单元格画不同的背景
                 {
                     e.Graphics.FillRectangle(new SolidBrush(FocusedBackColor), new Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Right - e.Bounds.Left, e.Bounds.Bottom - e.Bounds.Top));
                 }
             }
             catch { }
             #endregion
         }
     }
 }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: icprog/MiKe
 private void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
 {
     if (e.Node.Selected)
     {
         e.Appearance.BackColor = Color.LightSteelBlue;
     }
 }
コード例 #3
0
ファイル: ProOtherForm.cs プロジェクト: shansheng/QDJJ
        private void treeListEx1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            if (e.Node != null)
            {
                //获取编号深度
                DataRowView row = e.Node.TreeList.GetDataRecordByNode(e.Node) as DataRowView;
                if (row == null)
                {
                    return;
                }
                int id;


                id = ToolKit.ParseInt(row["UnID"]);
                int level = 0;
                if (e.Node.Level == 2) //单位工程取值
                {
                    level = -1;
                    if (e.Column.FieldName == "Combinedprice")
                    {
                        e.CellText = this.GetData(id, "QTXMHJ", level).ToString();
                    }
                    if (e.Column.FieldName == "Number")
                    {
                        e.CellText = GetFiledValue(id.ToString(), "Name").ToString();
                    }
                }
                if (e.Node.Level == 0)
                {//项目
                    id    = 0;
                    level = -3;
                    if (e.Column.FieldName == "Combinedprice")
                    {
                        e.CellText = this.GetData(id, "QTXMHJ", level).ToString();
                    }
                }
                if (e.Node.Level == 1)
                {//单项
                    level = -2;
                    if (e.Column.FieldName == "Combinedprice")
                    {
                        e.CellText = this.GetData(id, "QTXMHJ", level).ToString();
                    }
                }
                if (e.Column.ColumnType.Equals(typeof(decimal)))
                {
                    decimal m_value = ToolKit.ParseDecimal(e.CellValue);
                    if (m_value.Equals(0m))
                    {
                        e.CellText = string.Empty;
                    }
                }
            }
        }
コード例 #4
0
        private void TreeListCustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            if (!e.Column.FieldName.Equals("Material_Id"))
            {
                return;
            }
            var m = new Test.BOMData().GetMaterialById(Convert.ToInt32(e.CellValue));

            if (m == null)
            {
                return;
            }
            e.CellText = m.No + "," + m.Version + "," + m.Name + "," + "1000";
        }
コード例 #5
0
ファイル: JobListView.cs プロジェクト: yareda/backoffice
        private void organizationTreeList_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            var tree = sender as TreeList;

            if (e.Node == tree.FocusedNode)
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                var rect = new Rectangle(e.EditViewInfo.ContentRect.Left, e.EditViewInfo.ContentRect.Top,
                                         Convert.ToInt32(e.Graphics.MeasureString(e.CellText, organizationTreeList.Font).Width + 1),
                                         Convert.ToInt32(e.Graphics.MeasureString(e.CellText, organizationTreeList.Font).Height));

                e.Graphics.FillRectangle(SystemBrushes.Highlight, rect);
                e.Graphics.DrawString(e.CellText, organizationTreeList.Font, SystemBrushes.HighlightText, rect);
                e.Handled = true;
            }
        }
コード例 #6
0
        /// <summary>
        /// 重绘节点修改过的加粗
        /// </summary>
        /// <param name="e"></param>
        protected override void RaiseCustomDrawNodeCell(DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            base.RaiseCustomDrawNodeCell(e);
            if (e.Column.ColumnType == typeof(decimal))
            {
                e.CellText = ToolKit.TrimZero(e.CellText);
            }

            /*string str = string.Format("{0},{1}", e.Node.Id, e.Column.ColumnHandle);
             * if (this.EditedObject.Contains(str))
             * {
             *  e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
             * }
             * else
             * {
             *  e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, e.Appearance.Font.Style);
             * }*/
        }
コード例 #7
0
ファイル: ViewExplorer.cs プロジェクト: thachgiasoft/abc-erp
        void ViewTree_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            MyData obj = (MyData)this.GetDataRecordByNode(e.Node);

            if (obj == null || obj.InnerData == null)
            {
                return;
            }

            if (obj.InnerData is STViewGroupsInfo)
            {
                e.Appearance.Font = new Font(e.Appearance.Font, FontStyle.Bold);
            }

            if (e.Node.Selected)
            {
                e.Appearance.Font = new Font(e.Appearance.Font, e.Appearance.Font.Style | FontStyle.Underline);
            }
        }
コード例 #8
0
        private void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            var listloai = db.RoomCategorys.ToList();

            glueLoai.DataSource    = listloai;
            glueLoai.DisplayMember = "Tenloai";
            glueLoai.ValueMember   = "Maloai";
            TreeList tree = sender as TreeList;

            if (e.Node == tree.FocusedNode)
            {
                if (e.CellText != "Tất cả các phòng")
                {
                    gcDataList.BeginUpdate();
                    var list = (from p in db.Rooms
                                join pc in db.RoomCategorys on p.Maloai equals pc.Maloai
                                join pt in db.RoomTangs on p.Manhom equals pt.Manhom
                                where pt.Vitri == e.CellValue.ToString()
                                select p).ToList();
                    gcDataList.DataSource = new BindingList <Room>(list)
                    {
                        AllowNew = true
                    };
                    gcDataList.EndUpdate();
                    btnThem.Enabled = true;
                    var rt = db.RoomTangs.FirstOrDefault(m => m.Vitri == e.CellValue.ToString());
                    manhom = rt.Manhom;
                }
                else
                {
                    gcDataList.BeginUpdate();
                    var list = (from p in db.Rooms
                                from pc in db.RoomCategorys
                                where p.Maloai == pc.Maloai
                                select p).ToList();
                    gcDataList.DataSource = list;
                    gvDataList.OptionsNavigation.AutoFocusNewRow = true;
                    gcDataList.EndUpdate();
                    btnThem.Enabled = false;
                }
            }
        }
コード例 #9
0
ファイル: IndicatorsForm.cs プロジェクト: viserin/CryptoSharp
        private void TreeIndicators_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            if (e.Node == null || e.Node.Tag == null)
            {
                return;
            }


            var indicator = (IndicatorInfo)e.Node.Tag;

            var rect = new Rectangle();

            var blockSize = e.Bounds.Height / 2;

            rect.X      = e.Bounds.Width - 14;
            rect.Y      = e.Bounds.Y + blockSize / 2;
            rect.Width  = blockSize;
            rect.Height = blockSize;

            e.Graphics.FillRectangle(new SolidBrush(indicator.LineColor), rect);
        }
コード例 #10
0
        void Tree_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            ABCCommonTreeListNode obj = (ABCCommonTreeListNode)this.GetDataRecordByNode(e.Node);

            if (obj == null || (FieldNodeInfo)obj.InnerData == null)
            {
                return;
            }

            FieldNodeInfo data = (FieldNodeInfo)obj.InnerData;

            if (data.Type == FiledNodeType.Table || data.Type == FiledNodeType.List)
            {
                e.Appearance.Font = new Font(e.Appearance.Font, FontStyle.Bold);
            }

            if (e.Node.Selected)
            {
                e.Appearance.Font = new Font(e.Appearance.Font, e.Appearance.Font.Style | FontStyle.Underline);
            }
        }
コード例 #11
0
        private void tlBoPhan_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            s = e;
            TreeList tree = sender as TreeList;

            if (e.Node == tree.FocusedNode)
            {
                var listnv = db.NhanVien.OrderBy(m => m.Id).ToList();
                lstNV = listnv;
                if (e.CellText != "Bộ phận tổ chức")
                {
                    gcQuanTriNguoiDung.BeginUpdate();
                    var list = (from nv in lstNV
                                join bp in db.BoPhan on nv.MaNhom equals bp.MaNhom
                                where bp.TenNhom == e.CellValue.ToString()
                                select nv).ToList();
                    gcQuanTriNguoiDung.DataSource = new BindingList <NhanVien>(list)
                    {
                        AllowNew = true
                    };
                    gcQuanTriNguoiDung.EndUpdate();
                    btnThem.Enabled = true;
                    var mn = db.BoPhan.FirstOrDefault(m => m.TenNhom == e.CellValue.ToString());
                    manhom = mn.MaNhom;
                    value  = e.CellValue.ToString();
                }
                else
                {
                    gcQuanTriNguoiDung.BeginUpdate();
                    var list = lstNV;
                    gcQuanTriNguoiDung.DataSource = list;
                    gcQuanTriNguoiDung.EndUpdate();
                    btnThem.Enabled = false;
                }
            }
            //for(int i=0;i<gvQuantri.RowCount;i++)
            //{
            //    gvQuantri.SetRowCellValue(i, grcMatKhau, "***********");
            //}
        }
コード例 #12
0
        private void treeList_menu_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            try
            {
                TreeList lista = sender as TreeList;
                if (e.Node == lista.FocusedNode)
                {
                    e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                    Rectangle rectangulo = new Rectangle(e.EditViewInfo.ContentRect.Left,
                                                         e.EditViewInfo.ContentRect.Top,
                                                         Convert.ToInt32(e.Graphics.MeasureString(e.CellText, this.treeList_menu.Font).Width + 1),
                                                         Convert.ToInt32(e.Graphics.MeasureString(e.CellText, this.treeList_menu.Font).Height));
                    e.Graphics.FillRectangle(SystemBrushes.Highlight, rectangulo);
                    e.Graphics.DrawString(e.CellText, treeList_menu.Font, SystemBrushes.HighlightText, rectangulo);

                    e.Handled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #13
0
 private void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
 {
 }
コード例 #14
0
        private void treeListMenu_x_Usuario_x_Empresa_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            TreeList lista = sender as TreeList;

            if (e.Node == lista.FocusedNode)
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                Rectangle rectangulo = new Rectangle(e.EditViewInfo.ContentRect.Left,
                                                     e.EditViewInfo.ContentRect.Top,
                                                     Convert.ToInt32(e.Graphics.MeasureString(e.CellText, this.treeListMenu_x_Usuario_x_Empresa.Font).Width + 1),
                                                     Convert.ToInt32(e.Graphics.MeasureString(e.CellText, this.treeListMenu_x_Usuario_x_Empresa.Font).Height));
                e.Graphics.FillRectangle(SystemBrushes.Highlight, rectangulo);
                e.Graphics.DrawString(e.CellText, treeListMenu_x_Usuario_x_Empresa.Font, SystemBrushes.HighlightText, rectangulo);

                e.Handled = true;
            }
        }