Exemplo n.º 1
0
        // Here is the trick for the Background / Foreground Color
        // of the Cell - override the Paint method, with our
        // own functionality.
        protected override void Paint(
            System.Drawing.Graphics g,
            System.Drawing.Rectangle bounds,
            System.Windows.Forms.CurrencyManager source,
            int rowNum,              // Here is the Row Number
            System.Drawing.Brush backBrush,
            System.Drawing.Brush foreBrush,
            bool alignToRight)
        {
            // Do we have Subscribers - notify them if we have
            if (DataGridDisableCell != null)
            {
                // Initialize our Event with the current Row and Column Number
                DataGridDisableCellEventArgs e = new DataGridDisableCellEventArgs(rowNum, _col);

                // Notify Subscribers to call their EventHandlers - where they
                // can do whatever they want. After this we check the EnableValue
                // Flag, which may be set / unset by a Subscriber.
                DataGridDisableCell(this, e);

                // Set the Foreground / Back Color according to our Subscribers
                if (e.EnableValue)
                {
                    backBrush = Brushes.Moccasin;
                    foreBrush = Brushes.DarkBlue;
                }
            }

            // In any case (enabled or disabled) draw the Column using the Base Method
            base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
        }
Exemplo n.º 2
0
        // Here is the trick to emable / disable the TextBox
        // of the Cell - override the Edit method, with our
        // own functionality.
        protected override void Edit(
            System.Windows.Forms.CurrencyManager source,
            int rowNum,
            System.Drawing.Rectangle bounds,
            bool readOnly,
            string instantText,
            bool cellIsVisible)
        {
            // Do we have Subscribers - notify them if we have
            if (DataGridDisableCell != null)
            {
                // Initialize our Event with the current Row and Column Number
                DataGridDisableCellEventArgs e = new DataGridDisableCellEventArgs(rowNum, _col);

                // Notify Subscribers to call their EventHandlers - where they
                // can do whatever they want. After this we check the EnableValue
                // Flag, which may be set / unset by a Subscriber.
                DataGridDisableCell(this, e);

                readOnly = !e.EnableValue;
            }

            // Only call the Edit Method (which enables the TextBox in the DataGrid)
            // when the Enable Flag has been set by the Subscriber
            base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
        }
Exemplo n.º 3
0
        // Here is the trick for the Background / Foreground Color
        // of the Cell - override the Paint method, with our
        // own functionality.
        protected override void Paint(
            System.Drawing.Graphics g,
            System.Drawing.Rectangle bounds,
            System.Windows.Forms.CurrencyManager source,
            int rowNum,  // Here is the Row Number
            System.Drawing.Brush backBrush,
            System.Drawing.Brush foreBrush,
            bool alignToRight)
        {
            // Do we have Subscribers - notify them if we have
            if (DataGridDisableCell != null)
            {
                // Initialize our Event with the current Row and Column Number
                DataGridDisableCellEventArgs e = new DataGridDisableCellEventArgs(rowNum, _col);

                // Notify Subscribers to call their EventHandlers - where they
                // can do whatever they want. After this we check the EnableValue
                // Flag, which may be set / unset by a Subscriber.
                DataGridDisableCell(this, e);

                // Set the Foreground / Back Color according to our Subscribers
                if (e.EnableValue)
                {
                    backBrush = Brushes.Moccasin;
                    foreBrush = Brushes.DarkBlue;
                }
            }

            // In any case (enabled or disabled) draw the Column using the Base Method
            base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
        }
Exemplo n.º 4
0
        // Here is the trick to emable / disable the TextBox
        // of the Cell - override the Edit method, with our
        // own functionality.
        protected override void Edit(
            System.Windows.Forms.CurrencyManager source,
            int rowNum,
            System.Drawing.Rectangle bounds,
            bool readOnly,
            string instantText,
            bool cellIsVisible)
        {
            // Do we have Subscribers - notify them if we have
            if (DataGridDisableCell != null)
            {
                // Initialize our Event with the current Row and Column Number
                DataGridDisableCellEventArgs e = new DataGridDisableCellEventArgs(rowNum, _col);

                // Notify Subscribers to call their EventHandlers - where they
                // can do whatever they want. After this we check the EnableValue
                // Flag, which may be set / unset by a Subscriber.
                DataGridDisableCell(this, e);

                readOnly = !e.EnableValue;
            }

            // Only call the Edit Method (which enables the TextBox in the DataGrid)
            // when the Enable Flag has been set by the Subscriber
            base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
        }