The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I am looking for some sample code that lets you delete, insert, add a row in C# to the grid. I am also looking for some code that will do this with the currently selected row. I looked through a ton of the samples but didn't come across what I was looking for...
MSMohamed Suhaib Fahad A. Syncfusion Team April 28, 2010 10:07 AM UTC
Hi David,
The v8.2 Install comes with a Stock Exchange Demo sample,
Syncfusion\EssentialStudio\8.2.0.18\WPF\Grid.WPF\Samples\3.5\WindowsSamples\Grid Data Control - Advanced\Stock Exchange Demo\CS
This sample does Add/Remove/Updates in the underlying ItemsSource that is bound to the GridDataControl. The Grid would automatically reflect those changes.
If you want to delete the SelectedItem, In your code you can do something as below, Consider Orders is the collection bound to the Grid,
this.Orders.Remove(this.DataGrid.SelectedItem);
Please let me know if this helps.
Thanks, Fahad
DMDavid MecteauxApril 28, 2010 01:38 PM UTC
Hi thanks for the response.
I am curious....if you reorder the data in the grid (like with a sort) and you use the code that you showed me....that will still delete the correct row?
DMDavid MecteauxApril 28, 2010 02:09 PM UTC
Actually I do have one additional question. How can you get the integer index of the row that is selected on the grid?
VPVarun P Syncfusion Team May 3, 2010 08:44 AM UTC
Hi David,
Sorry for the delay in getting back to you.
Regarding the sorting, this looks like a bug, We would like you to create an incident with the Forum Title as the Incident description for further follow up.
Regarding to get the integer index of the selected row, you can use the following code.
var rowIndex = this.dataGrid.Model.CurrencyManager.CurrentRecordIndex;