C#winform DataGridView Control selects an entire row of effects when implemented, cancels the first row by default when selected by the secondary effect

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.