We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Getting the Row/Column index inside a RecordDeleted event

Hi, My grid is a GGC, and one of the columns in it has a ComboBox. In my RecordDeleted event, i want to get the Row index and Column index of a Column that contains a ComboBox i.e. the if the user deletes the second row from a GGC, is it possible to get the row index and column index of a column that contains the combobox on the row the user is deleting. here is my sample code: private void dataSheetControl_RecordDeleted(object sender, Syncfusion.Grouping.RecordEventArgs e) { int count = 0; foreach(GridVisibleColumnDescriptor cd in this.dataSheetControl.TableDescriptor.VisibleColumns) { count++; if (this.dataSheetControl.TableControl.Model.CellMod els.ContainsKey("ComboBox")) { int colIndex = count; break; } } DataRow current_row = this.GetRow(this.CurrentCell.RowIndex,colIndex); int id = Convert.ToInt32( current_row[ this.descriptor.PrimaryField.Name ] ); descriptor.DeleteListFromRelation(id); } This doesn''t seem to work because when a row is deleted, there is no current active cell. Actually what i''m looking for is a way to somehow get the Row and Column index of a cell that contains a combobox in the row being deleted. If it''s not possible to do it in the RecordDeleted event, is it possible to do it using the TableControlCurrentCellKeyDown event. here is the sample code for this event handler: public void dataSheetControl_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e) { if(e.Inner.KeyCode == Keys.Delete) { //my code here } } Regards David

1 Reply

AD Administrator Syncfusion Team July 7, 2005 04:54 AM

Why do you need the actual row and column index in the RecordDeleted event? It can be found if you really need it, but if you want just want teh value of this column from that record, then there are simpler ways to get it. These row and column index values can change as you sort things or move columns or group or ?? So, it is probably not a good thing to try to save these values for use later. Do you know the name of the column holding the combobox? If so, and all you want is the value, then you can use code like this to get it in the key down event.
private void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
	if(e.Inner.KeyCode == Keys.Delete)
	{
		if(this.gridGroupingControl1.Table.CurrentRecord != null)
		{
			Console.WriteLine(this.gridGroupingControl1.Table.CurrentRecord.GetValue("Col2"));
			//this.gridGroupingControl1.Table.CurrentRecord.Delete();
		}
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon