private void SetCellStyles()
        {
            cellStyles = new Hashtable();
            for (int j = 0; j < gridView1.DataRowCount; j++)
            {
                foreach (DevExpress.XtraGrid.Columns.GridColumn column in gridView1.Columns)
                {
                    string cellValue = gridView1.GetRowCellDisplayText(j, column);

                    // some Rule
                    if (cellValue.IndexOf('1') > 0)
                    {
                        AppearanceObject ap = new AppearanceObject();
                        ap.BackColor = Color.Red;
                        cellStyles.Add(new Point(column.AbsoluteIndex, j), ap); // Point is used here to identify a cell
                    }
                }
            }
        }
 public void ProcessFocusedRowChanged()
 {
     // some time consuming process
     for (int i = 0; i < 1000000; i++)
     {
         i = (i * 3) / 3;
     }
     // The indicator that the process is completed
     label1.Text = gridView1.GetRowCellDisplayText(
         gridView1.FocusedRowHandle, gridView1.Columns["RowName"]);
     label1.Refresh();
 }
Esempio n. 3
0
 private void gvExcelData_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
 {
     DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
     if (e.RowHandle >= 0)
     {
         string depart = view.GetRowCellDisplayText(e.RowHandle, view.Columns[headerList[0]]);
         if (depart == GlobalEnvironment.GlobalUser.GroupName)
         {
             e.Appearance.BackColor = Color.LightYellow;
         }
     }
 }
Esempio n. 4
0
 private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
 {
     DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
     if (e.RowHandle >= 0)
     {
         string category = view.GetRowCellDisplayText(e.RowHandle, view.Columns["Columns2"]);
         if (category.Contains("点"))
         {
             e.Appearance.BackColor = Color.Silver;
             e.Appearance.ForeColor = Color.Black;
         }
     }
 }
Esempio n. 5
0
 void gridView_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
 {
     DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
     if (e.RowHandle >= 0)
     {
         string category = view.GetRowCellDisplayText(e.RowHandle, view.Columns[2]);
         if (category == "是")
         {
             e.Appearance.BackColor = System.Drawing.Color.OrangeRed;
             //e.Appearance.BackColor2 = Color.SeaShell;
         }
         else
         {
             e.Appearance.BackColor = System.Drawing.Color.CornflowerBlue;
         }
     }
 }
Esempio n. 6
0
 private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
 {
     DevExpress.XtraGrid.Views.Grid.GridView View = sender as DevExpress.XtraGrid.Views.Grid.GridView;
     if (e.Column.FieldName == "sComPagada")
     {
         string category = View.GetRowCellDisplayText(e.RowHandle, View.Columns["sComPagada"]);
         if (category == "Si")
         {
             e.Appearance.BackColor  = Color.White;
             e.Appearance.BackColor2 = Color.Green;
         }
         else
         {
             e.Appearance.BackColor  = Color.White;
             e.Appearance.BackColor2 = Color.Maroon;
         }
     }
 }
Esempio n. 7
0
        //复制数据到剪贴板中
        private void dataCopy(DevExpress.XtraGrid.Views.Grid.GridView gridViewMain)
        {
            if (gridViewMain == null)
            {
                return;
            }
            string ret      = string.Empty;
            int    rowIndex = -1;
            var    rows     = gridViewMain.GetSelectedRows();
            var    focusCol = gridViewMain.FocusedColumn;

            if (focusCol == null || rows.Length == 0)
            {
                Clipboard.SetDataObject(string.Empty);
            }

            foreach (var index in rows)
            {
                if (rowIndex != index)
                {
                    if (!string.IsNullOrEmpty(ret))
                    {
                        ret += "\r\n";
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(ret))
                    {
                        ret += "\t";
                    }
                }

                ret     += gridViewMain.GetRowCellDisplayText(index, focusCol);
                rowIndex = index;
            }

            Clipboard.SetDataObject(ret);
        }
Esempio n. 8
0
 private void gridView2_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
 {
     DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
     if (e.Column.FieldName == "State")
     {
         string aa = view.GetRowCellDisplayText(e.RowHandle, view.Columns["State"]);
         if (aa.Contains("2"))
         {
             e.Appearance.ForeColor = Color.Green;
         }
         else if (aa.Contains("1"))
         {
             e.Appearance.ForeColor = Color.Red;
         }
         else if (aa.Contains("0"))
         {
             e.Appearance.ForeColor = Color.Black;
         }
         else
         {
             e.Appearance.ForeColor = Color.Silver;
         }
     }
 }
Esempio n. 9
0
        private static void SearchChildren(Control ctl, StringBuilder sb)
        {
            if ("DevExpress.XtraGrid.GridControl".Equals(ctl.GetType().ToString()) ||
                "RelayTest.Util.Common.BaseGridControl".Equals(ctl.GetType().ToString()))
            {
                DevExpress.XtraGrid.GridControl         gridCtl  = (DevExpress.XtraGrid.GridControl)ctl;
                DevExpress.XtraGrid.Views.Grid.GridView gridView = (DevExpress.XtraGrid.Views.Grid.GridView)gridCtl.FocusedView;

                for (int i = 0; i < gridView.RowCount; i++)
                {
                    foreach (DevExpress.XtraGrid.Columns.GridColumn gc in gridView.Columns)
                    {
                        sb.Append(gridView.GetRowCellDisplayText(i, gc).ToString());
                    }
                }
            }
            if ("DevExpress.XtraEditors.CheckEdit".Equals(ctl.GetType().ToString()) ||
                "RelayTest.Util.Common.BaseCheckEdit".Equals(ctl.GetType().ToString()))
            {
                DevExpress.XtraEditors.CheckEdit checkCtl = (DevExpress.XtraEditors.CheckEdit)ctl;
                sb.Append(checkCtl.Checked.ToString());
            }
            else
            {
                foreach (Control item in ctl.Controls)
                {
                    if (!item.Visible)
                    {
                        continue;
                    }

                    sb.Append(item.Text);
                    SearchChildren(item, sb);
                }
            }
        }