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
160
Bound UltraWinGrid: be notified of new rows insertion
posted

Hello,

I have an UltraWinGrid control which is bound to a DataTable.

A new row is inserted to this DataTable upon an user action.

The new row is inserted into the grid and appears successfully.

My problem now is that I want to be notified by an UltraGrid event of this row insertion.

The AfterRowInsert event does not fire in this case. I guess it only does when rows are inserted explicitely to the grid. As the row was inserted into the DataTable, UltraGrid does not fire this event.

It might trigger another one, but I have not found which yet?

Some people may probably advise me to detect this inside the DataTable itself, but it is not possible in my case because I'm encapsulating this specific grid' logic in my own class derived from UltraGrid, where I override methods like OnAfterInsert, etc.

This means I do not have access to the DataTable, declared a level above.

Here is a simplified example showing the issue.

I believe there must be an event or property to change to make the AfterRowInsert event trigger?

Thanks in advance.

namespace WindowsFormsApplication1
{
    using System;
    using System.Data;
    using System.Windows.Forms;
 
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        DataTable dt = new DataTable();
 
        private void Form1_Load(object sender, EventArgs e)
        {
            dt.Columns.Add("FirstName"typeof(string));
            dt.Columns.Add("LastName"typeof(string));
 
            dt.Rows.Add("Bill""Clinton");
            dt.Rows.Add("George""Bush");
 
            ultraGrid1.DataSource = dt;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            dt.Rows.Add("Barack""Obama");
        }
 
        private void ultraGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
        {
            MessageBox.Show("I got a new row. <- This never fires.");
        }
    }
}