C # How to Determine checkbox Selection in Windows dview

Source: Internet
Author: User

Recently, I am working on a small C # winform item. I used to add a new row to datawindow. the implementation method is to right-click the menu and a form is displayed. The new form has a dview, and the first column is a datagridviewcheckboxcolumn. the row of the selected checkbox must be added to the parent form data source. determine which selected

Foreach (maid DR in this. Maid)
{
Try
{
// Maid cbx = (maid) DR. cells [0];
// If (bool) cbx. formattedvalue)
If (dr. cells [0]. Selected)
{
Arrshiftcode. Add (dr. cells [1]. value );
Arrshiftgroup. Add (dr. cells [2]. value );
}
}
Catch (exception ex)
{
MessageBox. Show (ex. Message );
}}

The above is written in this way at the beginning. It is found that only the last one is true, and the others are false. The following code is used to query the information:

Foreach (maid DR in this. Maid)
{
Try
{
Maid cbx = (maid) DR. cells [0];
If (bool) cbx. formattedvalue)
{
Arrshiftcode. Add (dr. cells [1]. value );
Arrshiftgroup. Add (dr. cells [2]. value );
}
}
Catch (exception ex)
{
MessageBox. Show (ex. Message );
}
}

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.