예제 #1
0
        private void toolTip_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
        {
            if (e.SelectedControl == MainGridControl)
            {
                ToolTipControlInfo info = null;
                //Get the view at the current mouse position
                GridView view = MainGridControl.GetViewAt(e.ControlMousePosition) as GridView;
                if (view == null)
                {
                    return;
                }
                //Get the view's element information that resides at the current position
                GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition);
                //Display a hint for row indicator cells
                if (hi.HitTest == GridHitTest.RowIndicator || hi.HitTest == GridHitTest.RowCell && hi.Column.FieldName == "CondenserState")
                {
                    //An object that uniquely identifies a row indicator cell
                    object o    = hi.HitTest.ToString() + hi.RowHandle.ToString();
                    string text = "";

                    DataRow row = MainGridView.GetDataRow(hi.RowHandle);
                    if (Convert.ToInt64(row["CondenserState"]) == 0)
                    {
                        text = "Работоспособен";
                    }
                    else
                    {
                        text = "Неработоспособен";
                    }

                    info = new ToolTipControlInfo(o, text);
                }
                //Supply tooltip information if applicable, otherwise preserve default tooltip (if any)
                if (info != null)
                {
                    e.Info = info;
                }
            }
        }
예제 #2
0
        private void MainGridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column.FieldName == "CondenserState")
            {
                Rectangle rect    = e.Bounds;
                int       diametr = e.Bounds.Height - 4;
                rect.X     = e.Bounds.X + e.Bounds.Width / 2 - diametr / 2;
                rect.Y     = e.Bounds.Y + e.Bounds.Height / 2 - diametr / 2;
                rect.Width = rect.Height = diametr;

                DataRow row = MainGridView.GetDataRow(e.RowHandle);
                if (Convert.ToInt64(row["CondenserState"]) == 0)
                {
                    e.Graphics.FillEllipse(new SolidBrush(Color.LightGreen), rect);
                }
                else
                {
                    e.Graphics.FillEllipse(new SolidBrush(Color.Red), rect);
                }
                e.Graphics.DrawEllipse(new Pen(new SolidBrush(Color.Black)), rect);
                e.Handled = true;
            }
        }