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."); } } }
Hi,
There is no event for this in the WinGrid. In this case, the grid is not initiating the action, the grid is responding to notifications from the BindingManager, so it's a consumer of an event, not the originator of one.
You could hook into the notifications on the DataTable's IBindingList imlpementation, which is essentially what the grid does.
Thanks Mike,
I understand and that's what I assumed but I think it would be useful to have a way to get the grid to notify.
I mean, a new row was inserted in the grid (even though I agree it is the data source that actually changed) so the grid should be able to trigger an event when that happens.
I would prefer to write my grid-centric code without relying on the data-source's implementation detail at all. The code I want to perform is grid-related so I don't think replying to the datasource's event is the best place for this kind of code.
Maybe new methods like OnAfterDataSourceRowInserted, etc could be useful? Or a property to allow the existing events to trigger in such a case?
My