1 UI
2 Code
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.ComponentModel;4 usingSystem.Data;5 usingSystem.Drawing;6 usingSystem.Linq;7 usingSystem.Text;8 usingSystem.Threading.Tasks;9 usingSystem.Windows.Forms;Ten usingSystem.Xml.Linq; One A namespaceWindowsFormsApplication3 - { - Public Partial classForm1:form the { - PublicForm1 () - { - InitializeComponent (); + } - +list<user> datas =NewList<user>(); A at Private voidForm1_Load (Objectsender, EventArgs e) - { - loadxmlfile (); - - - /////////////////////////////////////////////////// in //cancels the negative effect that is selected by default on the first row -datagridview1.selectedrows[0]. Selected =false; to /////////////////////////////////////////////////// + - } the * Private voidLoadxmlfile () $ {Panax Notoginseng //when the form forms are loaded, the XML file is read -XDocument xmlfile = Xdocument.load ("1.xml"); theXElement root =Xmlfile.root; + A foreach(varIteminchRoot. Elements ()) the { +Datas. ADD (NewUser () {Shenghao = Item. Element ("Shenghao"). Value, Password = Item. Element ("Password"). Value}); - } $ $ //binding the list data to DataGridView -Datagridview1.datasource =datas; - the } - }Wuyi}
3 Show
C#winform DataGridView Control selects an entire row of effects when implemented, cancels the first row by default when selected by the secondary effect