Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144735 | May 20,2019 12:44 PM UTC | May 23,2019 01:07 PM UTC | WinForms | 6 |
![]() |
Tags: SfDataGrid |
// Add the below code in constructor or form loading
this.sfDataGrid.AllowDeleting = true;
this.sfDataGrid.Columns.Add(new GridButtonColumn()
{
MappingName = "Quantity",
HeaderText = "Remove",
AllowDefaultButtonText = true,
DefaultButtonText = "Remove this row"
});
this.sfDataGrid.CellButtonClick += sfDataGrid_CellButtonClick;
void sfDataGrid_CellButtonClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellButtonClickEventArgs e)
{
int _Dgdeletingrowindex = sfDataGrid.TableControl.ResolveToRecordIndex(sfDataGrid.CurrentCell.RowIndex);
// Delete record by based on the row index
sfDataGrid.View.RemoveAt(_Dgdeletingrowindex);
// Or you can call the below code the delete the selected record
// this.sfDataGrid.DeleteSelectedRecords();
}
|
// Under form loading method
this.sfDataGrid.AllowDeleting = true;
this.sfDataGrid.AutoGenerateColumns = false;
sfDataGrid.DataSource = data.OrdersListDetails;
this.sfDataGrid.Columns.Add(new GridButtonColumn()
{
MappingName = "Quantity",
HeaderText = "Remove",
AllowDefaultButtonText = true,
DefaultButtonText = "Remove this row"
});
this.sfDataGrid.CellButtonClick += sfDataGrid_CellButtonClick;
|
// Under form loading method
this.sfDataGrid.AllowDeleting = true;
this.sfDataGrid.AutoGenerateColumns = true;
this.sfDataGrid.AutoGeneratingColumn += sfDataGrid_AutoGeneratingColumn;
sfDataGrid.DataSource = data.OrdersListDetails;
void sfDataGrid_AutoGeneratingColumn(object sender, Syncfusion.WinForms.DataGrid.Events.AutoGeneratingColumnArgs e)
{
if (e.Column.MappingName == "Quantity")
{
GridButtonColumn column = new GridButtonColumn()
{
MappingName = "Quantity",
HeaderText = "Remove",
AllowDefaultButtonText = true,
DefaultButtonText = "Remove this row"
};
e.Column = column;
}
} |
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.
This page will automatically be redirected to the sign-in page in 10 seconds.