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

Removing Column in GroupingGrid

How to delete a row in a bound grouping grid? I noticed that by just selecting the field and pressing delete doesn''t work. I''ve created an unbound field, and changed it to a pushbutton type. what code goes into that button to delete the row from the grid and change the row state of the datatable to deleted. thanks in advanced!

5 Replies

AD Administrator Syncfusion Team November 11, 2004 09:04 AM UTC

Here is code that will delete the current record in a GridGroupingControl.
int pos = this.grid.Table.Records.IndexOf(this.grid.Table.CurrentRecord);
if(pos > - 1)
	this.grid.Table.Records[pos].Delete();


BH Bernard Herrok November 11, 2004 08:32 PM UTC

how do i check which column the button was clicked from?


AD Administrator Syncfusion Team November 11, 2004 11:01 PM UTC

Here is some code you can use in the ButtonClicked event.
private void gridGroupingControl1_TableControlPushButtonClick(object sender, GridTableControlCellPushButtonClickEventArgs e)
{
	int row = e.Inner.RowIndex;
	int col = e.Inner.ColIndex;
	GridTableCellStyleInfo style = e.TableControl.Model[row, col];
	//get some record data
	GridRecordRow grr = style.TableCellIdentity.Table.DisplayElements[row] as GridRecordRow;
	DataRowView drv = grr.GetData() as DataRowView;
	Console.WriteLine(drv[0].ToString() + " " + drv[1].ToString() );
}


BH Bernard Herrok November 15, 2004 01:49 AM UTC

for the code you posted bellow, that will only work if the row is selected. so it work work if i just click the delete button without first selecting the row. any ideas how i could do this? >Here is code that will delete the current record in a GridGroupingControl. > >
>int pos = this.grid.Table.Records.IndexOf(this.grid.Table.CurrentRecord);
>if(pos > - 1)
>	this.grid.Table.Records[pos].Delete();
>


AD Administrator Syncfusion Team November 15, 2004 07:24 AM UTC

Try this code.
private void gridGroupingControl1_TableControlPushButtonClick(object sender, GridTableControlCellPushButtonClickEventArgs e)
{
	int row = e.Inner.RowIndex;
	int col = e.Inner.ColIndex;
	GridTableCellStyleInfo style = e.TableControl.Model[row, col];
	GridRecordRow rec = style.TableCellIdentity.Table.DisplayElements[row] as GridRecordRow;
	if(rec != null)
	{
		int pos = this.gridGroupingControl1.Table.Records.IndexOf(rec.ParentRecord);
		if(pos > -1)
			this.gridGroupingControl1.Table.Records[pos].Delete();
	}
}

Loader.
Up arrow icon