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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Removing Column in GroupingGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

21462 Nov 11,2004 01:28 AM UTC Nov 15,2004 07:24 AM UTC Windows Forms 5
loading
Tags: GridControl
Bernard Herrok
Asked On November 11, 2004 01:28 AM UTC

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!

Administrator [Syncfusion]
Replied On 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();

Bernard Herrok
Replied On November 11, 2004 08:32 PM UTC

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

Administrator [Syncfusion]
Replied On 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() );
}

Bernard Herrok
Replied On 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();
>

Administrator [Syncfusion]
Replied On 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();
	}
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;