Hugoski_91
Hugoski_91

Reputation: 1

How to delete items from dataitem

How do I delete items from a DataItem wpf c#? What happens, is the following:

I fill a DataGrid with a DataItem

public class DataItem
{
public String Column1 {get; set};
public String Column2 {get; set};
public String Column3 {get; set};
public String Column4 {get; set};
public String Column5 {get; set};
}

DataGrid.Items.Add(new DataItem {Column1 = val1, Column2 = val2, Column3 = val3, Column4 = cantidad});

Then I print the columns that I want the DataGrid in a ticket with a FOREACH cycle

foreach (DataItem row in DataGrid.Items)
{
string quantity = row.Column4;
product string = row.Column2;
string amount = row.Column5;

ticket.AddItem (quantity, product, amount);
}

To remove items from the datagrid I do with a button

DataGrid.Items.Clear ();

Until there all right, add new elements to the DataGrid.

The problem is when I want to print new data in the DataGrid, because print the new data and the already-deleted data.

How do I eliminate definitively the DataItem data, when I clean the DataGrid?

In WindowsForms I do the same, with the syntax of C# and everything works excellent

Upvotes: 0

Views: 227

Answers (0)

Related Questions