WPF Data. Grid Control Performing Update and Delete Operations. I was recently working on a requirement to perform Update and Delete operations on a WPF Data. Grid control similar to what developers do in a ASP. I am having problems with deleting all records in a table with VB. NET. I am using this code to delete all records in the Contacts table For Each contact In. Create a CVB. NET kiosk application that runs on Windows and displays modern Web content using WPF or WinForms and a Browser control based on Chromium. This code first searches the selected Employee row using LINQ. After the row is found, the update operation is performed on it. In DataGrid, every Cell is in the form. In this article, we will learn LINQ To XML using some How Do I kind of examples. Here Mudassar Ahmed Khan has explained with an example, how to return JSON data object from WebMethod PageMethod in ASP. Net using C and VB. Net. In this example. How to read from ms word file in asp. Update List Using Linq In Vb.Net' title='Update List Using Linq In Vb.Net' />NET Grid control. The WPF Data. Grid is an excellent control to bind with collections and provides various events to work with. In this article, I have developed a small application using ADO. NET EF Entity Framework and WPF Data. Grid. The script for creating the Database table is in the db. Creating ADO. NET EF and WPF Project. Step 1 Open VS2. WPF project and name it as WPFData. Grid. Events. Step 2 To this project, add a new ADO. NET Entity Model. Name it as Company. EDMX.  From the wizard for ADO. NET EF, select Employee table created in SQL Server using the db. After the completion of the wizard, the following model will be generated Working with the WPF Data. Grid Control. Step 1 In the Main. WindowData. GridOperations. Text. Block and Data. Grid. Define columns for the Data. Grid for every corresponding column name of the Entity model, as shown below lt Window x ClassWPFDaat. Grid. Events. Main. WindowData. GridOperations        xmlnshttp schemas. TitleMain. WindowData. GridOperations Height4. Width9. 09         LoadedWindowLoaded    lt Grid    lt Data. Grid Auto. Generate. ColumnsFalse Height2. Horizontal. AlignmentLeft Margin1. Namedg. Emp Vertical. AlignmentTop Width6. Column. Width          Row. Edit. Endingdg. EmpRow. Edit. Ending Cell. Edit. Endingdg. EmpCell. Edit. Ending          Selection. Changeddg. EmpSelection. Changed         lt Data. Grid. Columns            lt Data. Grid. Text. Column BindingBinding Emp. No HeaderEmp. No                      Is. Read. OnlyTrue x Namedgr. Emp. No                            lt Data. Grid. Text. Column            lt Data. Grid. Text. Column BindingBinding Emp. Name HeaderEmp. Name                      Is. Read. OnlyTrue x Namedgr. Emp. Name                            lt Data. Grid. Text. Column            lt Data. Grid. Text. Column BindingBinding Salary, ModeTwo. Way                      HeaderSalary x Namedgr. Salary Is. Read. OnlyTrue                            lt Data. Grid. Text. Column            lt Data. Grid. Text. Column BindingBinding Dept. No, ModeTwo. Way                      HeaderDept. No x Namedgr. Dept. No Is. Read. OnlyTrue                            lt Data. Grid. Text. Column            lt Data. Grid. Template. Column                lt Data. Grid. Template. Column. Cell. Template                    lt Data. Template                        lt Button ContentUpdate x Namebtn. Update                                Clickbtn. UpdateClick lt Button                    lt Data. Template                lt Data. Grid. Template. Column. Cell. Template            lt Data. Grid. Template. Column            lt Data. Grid. Template. Column                lt Data. Grid. Template. Column. Cell. Template                    lt Data. Download Memtest Win 7 64 Bit. Template                        lt Button ContentDelete x Namebtn. Delete                                Clickbtn. DeleteClick lt Button                    lt Data. Template                lt Data. Grid. Template. Column. Cell. Template            lt Data. Grid. Template. Column        lt Data. Grid. Columns    lt Data. Grid    lt Text. Block Height5. Horizontal. AlignmentLeft Margin1. Nametext. Block. Vertical. AlignmentTop Width6. TextWPF Data. Grid for Update and Delete Operations                                Text. AlignmentCenter Font. FamilyVerdana Font. Size2. 8 lt Grid lt Window In the above XAML, using the Data. Grid. Template. Column, Update and Delete buttons are added. The following Data. Grid Events are used          Selection. Changedo    This event is raised when any row from the Data. Grid is selected. This returns an object of the binding source to the Data. Grid.          Cell. Edit. Endingo    This event is raised when any cell from the selected row is changed and the control is moved out of it. Row. Edit. Endingo    This event is raised when after editing all cells in the row, the focus from the row is changed. Step 2 In the Mainwindow. Xaml. csvb Windows loaded event, write the following code. This code will create an instance of the Entity Model and the data will be displayed in Data. Grid Cprivatevoid WindowLoadedobject sender, Routed. Event. Args e    obj. Context new. Company. Entities    dg. Emp. Items. Source obj. Context. Employee VB. NETPrivate. Sub WindowLoadedBy. Val sender As. Object, By. Val e As Routed. Event. Args      obj. Context New Company. Entities      dg. Emp. Items. Source obj. Context. Employee. End. Sub. Step 3 In the Selection. Changed event of the Data. Grid, write the following code. Cprivatevoid dg. EmpSelection. Changedobject sender, Selection. Changed. Event. Args e    obj. Emp. To. Edit dg. Emp. Selected. Item as. Employee VB. NETPrivate. Sub dg. EmpSelection. ChangedBy. Val sender As. Object, By. Val e As Selection. Changed. Event. Args      obj. Emp. To. Edit Try. Castdg. Emp. Selected. Item, EmployeeEnd. Sub. This will return an index of the Employee entity object. Step 4 In the XAML, the Data. Grid columns are made read only using Is. Read. Only property set to false. Now since Salary and Dept. No can be updated, on the click event of the Update button, the following code is written. This code changes the columns for Salary and Dept. No in edit mode. Cprivatevoid btn. UpdateClickobject sender, Routed. Event. Args e    is. Update. Mode true    dg. Emp. Columns2. Is. Read. Only false    dg. Emp. Columns3. Is. Read. Only false VB. NETPrivate. Sub btn. UpdateClickBy. Val sender As. Object, By. Val e As Routed. Event. Args      is. Update. Mode True      dg. Emp. Columns2. Is. Read. Only False      dg. Emp. Columns3. Is. Read. Only False. End. Sub. Performing Update Operation in the WPF Data. Grid. Step 5 Write the following code in the Cell. Edit. Ending event. Cprivatevoid dg. EmpCell. Edit. Endingobject sender, Data. Grid. Cell. Edit. Ending. Event. Args e    if is. Update. Mode The Row is edited            Employee Temp. Emp from emp in obj. Context. Employee                            where emp. Emp. No obj. Emp. To. Edit. Emp. No                            select emp. First        Framework. Element element1 dg. Emp. Columns2. Get. Cell. Contente. Row        if element1. Get. Type typeofText. Box                    var xx. Salary Text. Boxelement1. Text            obj. Emp. To. Edit. Salary Convert. To. Int. 32xx. Salary               Framework. Element element2 dg. Emp. Columns3. Get. Cell. Contente. Row        if element2. Get. Type typeofText. Box                    var yy. Dept. No Text. Boxelement2. Text            obj. Emp. To. Edit. Dept. No Convert. To. Int. Dept. No                    VB. NETPrivate. Sub dg. EmpCell. Edit. EndingBy. Val sender As. Object, By. Val e As Data. Grid. Cell. Edit. Ending. Event. Args      If is. Update. Mode ThenThe Row is edited            Dim Temp. Emp As Employee                 From emp In obj. Context. Employee                Where emp. Emp. No obj. Emp.