Beispiel #1
0
        protected internal override void Edit(CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible)
        {
#endif
            grid.SuspendLayout();

            textbox.TextChanged -= new EventHandler(textbox_TextChanged);

            textbox.TextAlign = alignment;

            bool ro = false;

            ro = (TableStyleReadOnly || ReadOnly || readOnly);

            if (!ro && instantText != null)
            {
                textbox.Text = instantText;
                textbox.IsInEditOrNavigateMode = false;
            }
            else
            {
                textbox.Text = GetFormattedValue(source, rowNum);
            }

            textbox.TextChanged += new EventHandler(textbox_TextChanged);

            textbox.ReadOnly = ro;
            textbox.Bounds   = new Rectangle(new Point(bounds.X + offset_x, bounds.Y + offset_y),
                                             new Size(bounds.Width - offset_x - 1, bounds.Height - offset_y - 1));

            textbox.Visible = cellIsVisible;
            textbox.SelectAll();
            textbox.Focus();
            grid.ResumeLayout(false);
        }
        /// <summary>
        ///    <para>Prepares a cell for editing.</para>
        /// </summary>
        protected internal override void Edit(CurrencyManager source,
                                              int rowNum,
                                              Rectangle bounds,
                                              bool readOnly,
                                              string displayText,
                                              bool cellIsVisible)
        {
            DebugOut("Begining Edit, rowNum :" + rowNum.ToString(CultureInfo.InvariantCulture));

            Rectangle originalBounds = bounds;

            edit.ReadOnly = readOnly || ReadOnly || DataGridTableStyle.ReadOnly;

            edit.Text = GetText(GetColumnValueAtRow(source, rowNum));
            if (!edit.ReadOnly && displayText != null)
            {
                // tell the grid that we are changing stuff
                DataGridTableStyle.DataGrid.ColumnStartedEditing(bounds);
                // tell the edit control that the user changed it
                edit.IsInEditOrNavigateMode = false;
                edit.Text = displayText;
            }

            if (cellIsVisible)
            {
                bounds.Offset(xMargin, 2 * yMargin);
                bounds.Width  -= xMargin;
                bounds.Height -= 2 * yMargin;
                DebugOut("edit bounds: " + bounds.ToString());
                edit.Bounds = bounds;

                edit.Visible = true;

                edit.TextAlign = Alignment;
            }
            else
            {
                edit.Bounds = Rectangle.Empty;
                // edit.Bounds = originalBounds;
                // edit.Visible = false;
            }

            edit.RightToLeft = DataGridTableStyle.DataGrid.RightToLeft;

            edit.Focus();

            editRow = rowNum;

            if (!edit.ReadOnly)
            {
                oldValue = edit.Text;
            }

            // select the text even if the text box is read only
            // because the navigation code in the DataGridTextBox::ProcessKeyMessage
            // uses the SelectedText property
            if (displayText == null)
            {
                edit.SelectAll();
            }
            else
            {
                int end = edit.Text.Length;
                edit.Select(end, 0);
            }

            if (edit.Visible)
            {
                DataGridTableStyle.DataGrid.Invalidate(originalBounds);
            }
        }