Exemplo n.º 1
0
        private void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (gridView.FocusedRowHandle < 0 && sender.GetType() != typeof(GridView))
            {
                return;
            }

            try
            {
                if (gridView.IsRowSelected(e.RowHandle) || gridView.FocusedRowHandle == e.RowHandle)
                {
                    Rectangle bounds = e.Bounds; // rowInfo.Bounds;
                    bounds.X     -= 1;
                    bounds.Width += 2;
                    if (null == m_focus_pen)
                    {
                        m_focus_pen = new Pen(Brushes.OrangeRed, 2);
                    }
                    e.Graphics.DrawLine(m_focus_pen, new Point(bounds.X, bounds.Y), new Point(bounds.X + bounds.Width, bounds.Y));
                    e.Graphics.DrawLine(m_focus_pen, new Point(bounds.X, bounds.Y + bounds.Height), new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height));
                }

                switch (e.Column.FieldName)
                {
                case "display_index":
                {
                    e.DisplayText = (gridControl.FocusedView.RowCount - e.RowHandle).ToString();
                }
                break;

                case "state_cd":
                {
                    //Debug.WriteLine("e.Column.FieldName : " + e.Column.FieldName);
                    //Debug.WriteLine("ObjOrder.getStateString(state_cd) : " + ObjOrder.getStateString(state_cd));
                    int    state_cd = (int)e.CellValue;
                    string text     = ObjOrder.getStateString(state_cd);
                    Bitmap img      = ObjOrder.getStateImage(state_cd);
                    if (img != null)
                    {
                        Point pos = new Point();
                        pos.X = e.Bounds.Location.X + 2;
                        pos.Y = e.Bounds.Location.Y + ((e.Bounds.Height - img.Height) / 2);

                        e.Graphics.DrawImage(img, pos.X, pos.Y, img.Width, img.Height);

                        int       margin_x = img.Width + 4;
                        Rectangle rect     = new Rectangle(e.Bounds.X + margin_x, e.Bounds.Y, e.Bounds.Width - margin_x, e.Bounds.Height);
                        e.Appearance.DrawString(e.Cache, text, rect);

                        e.Handled = true;
                    }
                }
                break;

                case "call_num":
                {
                    e.DisplayText = ((null == e.CellValue || 8 > e.CellValue.ToString().Length) ? e.CellValue.ToString() : KnUtil.formatTelNumber(e.CellValue.ToString()));
                }
                break;
                }
            }
            catch (Exception ex)
            {
                String erro_msg = (null == ex.Message ? "error - OrderList_gridView_CustomDrawCell" : ex.Message);
                TsLog.writeLog(erro_msg);
                //Debug.Assert(false, erro_msg);
            }
        }
Exemplo n.º 2
0
        private void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (gridView.FocusedRowHandle < 0 && sender.GetType() != typeof(GridView))
            {
                return;
            }

            try
            {
                switch (e.Column.FieldName)
                {
                case "display_index":
                {
                    e.DisplayText = (gridControl.FocusedView.RowCount - e.RowHandle).ToString();
                }
                break;

                case "store_tel":
                {
                    e.DisplayText = ((null == e.CellValue || 8 > e.CellValue.ToString().Length) ? e.CellValue.ToString() : KnUtil.formatTelNumber(e.CellValue.ToString()));
                }
                break;
                }
            }
            catch (Exception)
            {
            }
        }