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

Looking for a sampke that adds, deletes in C# code

Hi,

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...

4 Replies

MS Mohamed 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


DM David Mecteaux April 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?


DM David Mecteaux April 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?


VP Varun 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;

Please let me know if you have any queries.

Thanks,
Varun

Loader.
Live Chat Icon For mobile
Up arrow icon