Gets the selected row on the DataGridView and converts to a DataRow type

Source: Internet
Author: User

Recently, because of work need, regain WinForm.

Using the dev plugin before, rarely using native WinForm, is unfamiliar with the use of many of its controls. So, for the last few days, practice WinForm common controls.

Starting today to see the DataGridView this common control, when you want to implement the data grid when a row is selected, we generally want to get a row of data of the DataRow, because it is convenient to operate. Searched a few pages, and did not find the desired, but also see the individual netizens many years ago, the forum mentioned similar to this problem, but did not find a practical solution in the post. Here, the implementation of their own code to paste out, easy to see.

Just stick to the key code below, and believe it can be understood at a glance.

DataGridViewRow gridrow = datagridview1.selectedrows[0== Row_view. DataView.Table.Clone (); // Cloning a DataTable structure dt. ImportRow (Row_view. ROW); // Copy the target DataRow data into the new DataTable

Gets the selected row on the DataGridView and converts to a DataRow type

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.