SelectionChanged event not being fired.

Hi,
I am using Syncfusion version 4.4.0.51. I am using virtual Grid. When selection changes, the SelectionChanged event is fired. But when a selected row is deleted, this event is not fired. Let me know how to resolve this issue.

Regards,
Harshal



3 Replies

HA haneefm Syncfusion Team July 16, 2007 07:48 PM UTC

Hi Harshal,

You can handle the RowsRemoving/RowsRemoved event to resolve this issue. Grid.Model.RowsRemoving is fired when grid.Model.Rows.RemoveRange is called. This method is normally only called for a GridControl to actually remove rows from the GridControls internal storage. Below is a code snippet.

this.gridControl1.RowsRemoving += new Syncfusion.Windows.Forms.Grid.GridRangeRemovingEventHandler(gridControl1_RowsRemoving);

void gridControl1_RowsRemoving(object sender, Syncfusion.Windows.Forms.Grid.GridRangeRemovingEventArgs e)
{
Console.WriteLine("Rows Removing....!");
}
Best regards,
Haneef


HA Harshal July 18, 2007 02:20 PM UTC

Hi,

I am actually using virtual grid. The rows are deleted from the DataTable where the data is actually stored.

See the below code snippet:

Assume row 1 is selected.
dataTable.Rows.RemoveAt(1);
gridControl1.ResetVolatileData();
gridControl1.Refresh();

In the above scenario the SelectionChanged event is not fired.
Please let me know to work around this issue.

Regards,
Harshal



RA Rajagopal Syncfusion Team July 18, 2007 06:23 PM UTC

Hi Harshal,

You can listen to the RowDeleted event of the DataTable and clear the existing selection there to make the SelectionChanged trigger. Please try the code below.

// RowDeleted event of the Datatable
dt.RowDeleted += new DataRowChangeEventHandler(dt_RowDeleted);

private void dt_RowDeleted(object sender, DataRowChangeEventArgs e)
{
if(e.Action == DataRowAction.Delete)
{
this.grid.Selections.Clear();
this.grid.Selections.Add(GridRangeInfo.Row(this.grid.CurrentCell.RowIndex));
}
}

Let me know if this helps.

Regards,
Rajagopal

Loader.
Up arrow icon