DataGridView Edit Status and Currentcelldirtystatechanged

Source: Internet
Author: User

Problem Description:

It is strange to use some controls in DataGridView, such as in a column such as Datagridviewcombocolumn or Datagridviewcheckboxcolumn, when the user changes, For example, a Datagridviewcombocell changes the options, Datagridviewcheckboxcell has been checked, does not immediately take effect, but into the editing state. A check box, when you tick the result tick is not out, only when you change a line of the end of the editing state of the time will change, so it will be annoying when used up ... The normal use of such controls should be processed immediately after the change without going into the editing state (for example, when a ComboBox selects a subkey, if there are other related to the display, the child should be updated immediately, instead of waiting for the user to wait for the return of the action to update), This will make the user experience a little bit more comfortable.

Treatment methods:

Locate the currentcelldirtystatechanged in the DataGridView event and trigger the change immediately when the user enters the editor. You can decide whether you want to enter an edit or commit the current edit in the Change event.

Private void Datagridview1_currentcelldirtystatechanged (object  Sender,eventargs e) {    /*     * Here can be added to determine whether it is necessary to submit immediately    , if not the return */    if (Datagridview1.iscurrentcelldirty)    {        datagridview1.commitedit (datagridviewdataerrorcontexts.commit);    }}

When the data is submitted immediately, the Cellvaluechanged event is triggered and the Cellvalidating event is not triggered.

DataGridView Edit Status and Currentcelldirtystatechanged

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.