Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
UltraGrid infinite CellDataError loop (in closing MDI form)
posted

Hi there,

I encountered an interesting error that blocks all user input to the application, and have created a small sample project to demonstrate it.

The error loop occurs when invalid data is entered into a cell (e.g. "three" in a cell expecting an integer), and (while the cell is still active) the MDI child form containing the grid control is closed.

The UltraGrid (to exhibit the full bad behaviour) needs to be contained within another control which itself is contained within an MDI child form.

The MDI Parent form needs to have at least two child forms, or the error box will only fire two or three times, rather than in a loop.

Here some code that demonstrates the problem.

    
using System;
using System.Data;
using System.Windows.Forms;
using Infragistics.Win.UltraWinGrid;

    public class ContainerForm : Form
    {
        [STAThread]
        static void Main()
        {
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new ContainerForm());
        }

        public ContainerForm()
        {
            this.InitializeComponent();
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();

            // 
            // ContainerForm
            // 
            this.ClientSize = new System.Drawing.Size(284, 262);
            this.IsMdiContainer = true;
            this.Name = "ContainerForm";
            this.Text = "Type some non-numeric text into the integer-only cells in the grid, then close the form";
            this.Shown += new System.EventHandler(this.ContainerForm_Shown);
            this.ResumeLayout(false);

        }

        private void ContainerForm_Shown(object sender, EventArgs e)
        {
            ChildForm form1 = new ChildForm();
            form1.MdiParent = this;
            form1.Show();

            ChildForm form2 = new ChildForm();
            form2.MdiParent = this;
            form2.Show();
        }
    }

    public class ChildForm : Form
    {
        private IntegerGridContainer gridControl;

        private DataTable dataSource;

        public ChildForm()
        {
            this.gridControl = new IntegerGridContainer();
            this.Controls.Add(this.gridControl);

            // Set up grid with an integer only column.
            dataSource = new DataTable("TableName");
            dataSource.Columns.Add("Integer", typeof(int));
            this.gridControl.DataSource = dataSource;
        }
    }

    public class IntegerGridContainer : UltraGrid
    {
        public IntegerGridContainer()
        {
            // Create UltraGrid
            this.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.TemplateOnBottom;
            this.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.EditAndSelectText;
        }
    }

 
I would welcome any suggestions, particularly if the fix does not alter the grid's behaviour the rest of the time.
On a related note, is it possible to disable or alter the appearance of the message box that appears when there are Data Errors "Unable to update the data value..." or when the user is deleting a row, etc?

Many Thanks,
Tom

Parents Reply Children