[Mono-bugs] [Bug 457112] New: DataGridView: PrepareEditingControlForEdit method not called

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Dec 7 11:41:57 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=457112


           Summary: DataGridView: PrepareEditingControlForEdit method not
                    called
           Product: Mono: Class Libraries
           Version: SVN
          Platform: x86
        OS/Version: Windows Vista
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: kobruleht2 at hot.ee
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


To reproduce, run code.

Observed: Messagebox does not appear. Pressing t terminates application.

Expected: Messagebox should appear.


using System;
using System.Windows.Forms;
using System.ComponentModel;

class Supplier
{
    public string Name { get; set; }
}

class Form1 : Form
{
    [STAThread]
    static void Main()
    {
        Application.Run(new Form1());
    }

    public Form1()
    {
        DataGridView grid = new DataGridView();
        grid.EditMode = DataGridViewEditMode.EditOnEnter;
        ComboBoxColumn comboBoxColumn = new ComboBoxColumn();
        ComboBoxCell ComboBoxCell = new ComboBoxCell();
        comboBoxColumn.CellTemplate = ComboBoxCell;
        grid.Columns.Add(comboBoxColumn);
        BindingList<Supplier> l = new BindingList<Supplier>();
        comboBoxColumn.DataSource = l;
        comboBoxColumn.DisplayMember = "Name";
        comboBoxColumn.ValueMember = "Name";
        l.Add(new Supplier() { Name = "test" });
        grid.DataSource = l;
        Controls.Add(grid);
    }

    class ComboBoxColumn : DataGridViewComboBoxColumn { }

    class ComboBoxCell : DataGridViewComboBoxCell
    {
        public override Type EditType
        {
            get
            {
                return typeof(ComboBoxEditingControl);
            }
        }

    }

    class ComboBoxEditingControl : ComboBox, IDataGridViewEditingControl
    {
        protected int rowIndex;
        protected DataGridView dataGridView;
        protected bool valueChanged = false;

        protected override void OnTextChanged(EventArgs e)
        {
            base.OnTextChanged(e);
            NotifyDataGridViewOfValueChange();
        }

        protected virtual void NotifyDataGridViewOfValueChange()
        {
            valueChanged = true;
            if (dataGridView != null)
            {
                dataGridView.NotifyCurrentCellDirty(true);
            }
        }

        public Cursor EditingPanelCursor
        {
            get
            {
                return Cursors.IBeam;
            }
        }

        public DataGridView EditingControlDataGridView
        {
            get
            {
                return dataGridView;
            }
            set
            {
                dataGridView = value;
            }
        }

        public object EditingControlFormattedValue
        {
            set
            {
                if (value.ToString() != Text)
                {
                    Text = value.ToString();
                    NotifyDataGridViewOfValueChange();
                }
            }

            get
            {
                return Text;
            }
        }

        public object
GetEditingControlFormattedValue(DataGridViewDataErrorContexts
        context)
        {
            return Text;
        }



        public void PrepareEditingControlForEdit(bool selectAll) {


            MessageBox.Show(dataGridView.CurrentCell.ToString());
        }

        public bool RepositionEditingControlOnValueChange
        {
            get
            {
                return false;
            }
        }

        public int EditingControlRowIndex
        {
            get
            {
                return rowIndex;
            }

            set
            {
                rowIndex = value;
            }
        }

        public void ApplyCellStyleToEditingControl(DataGridViewCellStyle
dataGridViewCellStyle)
        {
            DropDownStyle = ComboBoxStyle.DropDown;
        }

        public bool EditingControlWantsInputKey(Keys keyData, bool
dataGridViewWantsInputKey)
        {
            return !dataGridViewWantsInputKey;
        }

        public bool EditingControlValueChanged
        {

            get
            {
                return valueChanged;
            }
            set
            {
                valueChanged = value;
            }
        }
    }
}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list