示例#1
0
        void Form1_Load(object sender, System.EventArgs e)
        {
            // load some data
            string           conn = GetConnectionString();
            string           sql  = "select * from employees";
            OleDbDataAdapter da   = new OleDbDataAdapter(sql, conn);
            DataTable        dt   = new DataTable();

            da.Fill(dt);

            // bind to grid
            _flex.DataSource = dt;

            // hide Notes column (we'll use CellNotes instead)
            _flex.Cols["Notes"].Visible = false;

            // create cell notes for every employee
            int noteColumn = _flex.Cols["FirstName"].Index;

            for (int r = _flex.Rows.Fixed; r < _flex.Rows.Count; r++)
            {
                // create note
                CellNote note = new CellNote(_flex[r, "Notes"] as string);

                // attach note to "FirstName" column
                CellRange rg = _flex.GetCellRange(r, noteColumn);
                rg.UserData = note;
            }

            // create manager to display/edit the cell notes
            CellNoteManager mgr = new CellNoteManager(_flex);
        }
示例#2
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // set up grid
            _flex.Cols.Count             = 2;
            _flex.Rows.Count             = 7;
            _flex.Cols[0].Caption        = "Item";
            _flex.Cols[1].Caption        = "Value";
            _flex.Styles.Fixed.BackColor = Color.DarkGray;
            _flex.Styles.Fixed.ForeColor = Color.White;

            // create styles with data types, formats, etc
            CellStyle cs = _flex.Styles.Add("emp");

            cs.DataType  = typeof(string);
            cs.ComboList = "|Tom|Dick|Harry";
            cs.ForeColor = Color.Navy;
            cs.Font      = new Font(Font, FontStyle.Bold);

            cs           = _flex.Styles.Add("date");
            cs.DataType  = typeof(DateTime);
            cs.Format    = "dd-MMM-yy";
            cs.ForeColor = Color.DarkGoldenrod;

            cs           = _flex.Styles.Add("curr");
            cs.DataType  = typeof(decimal);
            cs.Format    = "c";
            cs.ForeColor = Color.DarkGreen;
            cs.Font      = new Font(Font, FontStyle.Bold);

            cs            = _flex.Styles.Add("bool");
            cs.DataType   = typeof(bool);
            cs.ImageAlign = ImageAlignEnum.CenterCenter;

            // show captions
            _flex[1, 0] = "Employee";
            _flex[2, 0] = "Start";
            _flex[3, 0] = "End";
            _flex[4, 0] = "Amount";
            _flex[5, 0] = "Discount";
            _flex[6, 0] = "Active";

            // assign styles to editable cells
            CellRange rg = _flex.GetCellRange(1, 1);

            rg.Style = _flex.Styles["emp"];

            rg       = _flex.GetCellRange(2, 1, 3, 1);
            rg.Style = _flex.Styles["date"];

            rg       = _flex.GetCellRange(4, 1, 5, 1);
            rg.Style = _flex.Styles["curr"];

            rg       = _flex.GetCellRange(6, 1);
            rg.Style = _flex.Styles["bool"];
        }
示例#3
0
        // method 2: use styles to accomplish the same thing
        private void _flex2_CellChanged(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
        {
            if (_flex2.Cols[e.Col].Name == "UserDef" && _flex2[e.Row, "UserDef"] is bool)
            {
                // create style if we have to
                CellStyle s = _flex2.Styles["Yellow"];
                if (s == null)
                {
                    s           = _flex2.Styles.Add("Yellow");
                    s.BackColor = Color.Yellow;
                }

                // apply style based on cell value
                CellRange rg = _flex2.GetCellRange(e.Row, _flex2.Cols["Length"].Index);
                rg.Style = ((bool)_flex2[e.Row, "UserDef"])? s: null;
            }
        }
示例#4
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // populate grid
            Random rnd = new Random();

            _flex.Rows.Count = 14;
            _flex[0, 1]      = "Direction";
            _flex[0, 2]      = "Region";
            CellRange rg = _flex.GetCellRange(0, 3, 0, _flex.Cols.Count - 1);

            rg.Data = "Rnd";
            for (int r = 1; r < _flex.Rows.Count; r++)
            {
                _flex[r, 0] = r;
                _flex[r, 1] = (r < 7)? "Inbound": "Outbound";
                _flex[r, 2] = (r < 3)? "North": (r < 7)? "South": (r < 10)? "East": "West";
                for (int c = 3; c < _flex.Cols.Count; c++)
                {
                    _flex[r, c]          = rnd.Next(1000);
                    _flex.Cols[c].Format = "#,###";
                }
            }

            // set up styles
            CellStyle s = _flex.Styles[CellStyleEnum.Subtotal0];

            s.BackColor = Color.Black;
            s.ForeColor = Color.White;
            s.Font      = new Font(_flex.Font, FontStyle.Bold);
            s           = _flex.Styles[CellStyleEnum.Subtotal1];
            s.BackColor = Color.DarkBlue;
            s.ForeColor = Color.White;
            s           = _flex.Styles[CellStyleEnum.Subtotal2];
            s.BackColor = Color.DarkRed;
            s.ForeColor = Color.White;

            // more setup
            _flex.AllowDragging         = AllowDraggingEnum.None;
            _flex.AllowEditing          = false;
            _flex.Cols[0].WidthDisplay /= 3;
            _flex.Tree.Column           = 1;

            // show totals
            UpdateTotals();
        }
示例#5
0
        void PintarCelda(C1.Win.C1FlexGrid.C1FlexGrid Objeto, int n_Fila1, int n_Columna1, int n_Fila2, int n_Columna2, Color n_Color)
        {
            CellRange rg = Objeto.GetCellRange(n_Fila1, n_Columna1, n_Fila2, n_Columna2);

            rg.StyleNew.ForeColor = n_Color;
        }
        // calculate border widths taking neighbor cells into account
        private Margins GetBorderMargins(int row, int col)
        {
            // initialize return value
            Margins m = new Margins(0, 0, 0, 0);

            // check whether this cell has a border
            CellRange rg = _flex.GetCellRange(row, col);

            if (rg.Style == null || rg.Style.Name != "Border")
            {
                return(m);
            }

            // check whether this cell is at the top of the range
            m.Top = _bdrOutside;
            if (row > _flex.Rows.Fixed)
            {
                rg.r1 = rg.r2 = row - 1;
                if (rg.Style != null && rg.Style.Name == "Border")
                {
                    m.Top = 0;
                }
                rg.r1 = rg.r2 = row;
            }

            // check whether this cell is at the left of the range
            m.Left = _bdrOutside;
            if (col > _flex.Cols.Fixed)
            {
                rg.c1 = rg.c2 = col - 1;
                if (rg.Style != null && rg.Style.Name == "Border")
                {
                    m.Left = 0;
                }
                rg.c1 = rg.c2 = col;
            }

            // check whether this cell is at the bottom of the range
            m.Bottom = _bdrOutside;
            if (row < _flex.Rows.Count - 1)
            {
                rg.r1 = rg.r2 = row + 1;
                if (rg.Style != null && rg.Style.Name == "Border")
                {
                    m.Bottom = _bdrInside;
                }
                rg.r1 = rg.r2 = row;
            }

            // check whether this cell is at the right of the range
            m.Right = _bdrOutside;
            if (col < _flex.Cols.Count - 1)
            {
                rg.c1 = rg.c2 = col + 1;
                if (rg.Style != null && rg.Style.Name == "Border")
                {
                    m.Right = _bdrInside;
                }
                rg.c1 = rg.c2 = col;
            }

            // done
            return(m);
        }