Some related applications of datagridviewcomboboxcolumn in DataGridView (i) Trigger event when its value is changed--go to

Source: Internet
Author: User

turn fromhttps://maodaili.de/mao.php?u=a%2FMrbEvUE8PnCuc7FrhJi0Rqd3kmOBHPZUbcJ1c2hbJUK0RYWpAf4lhIOddItP% 2bki2z5pzeivpy%3d&b=15Some related applications of datagridviewcomboboxcolumn in DataGridView (i) triggering an event when its value changesCategory: Form2008-07-23 23:27 2451 people read reviews (4) favorite reports Objectbutton today in Csdn back to a post to see a DataGridView problem, need to trigger the event in DataGridViewComboBoxCell to be able to solve.

Open vs test did not find can directly trigger the DataGridViewComboBoxCell in the ComboBox in the value of the event, depressed for half a day, look closely at MSDN there is a solution to the example, all blame themselves did not look carefully:

You first need to trigger the first event: currentcelldirtystatechanged

And calling the Datagridview.commitedit method in the event [about Commitedit MSDN explains the following: commits the changes in the current cell to the data cache, but does not end the edit mode. ]

So that the event that we care about cellvaluechanged can be triggered smoothly.

Call the following MSDN the source code provided for this workaround is for reference only:)

This event handler manually raises the Cellvaluechanged event//by calling the Commitedit method.void datagridview1_cur Rentcelldirtystatechanged (object sender, EventArgs e) {if (datagridview1.iscurrentcelldirty) {Datagridvie W1.    Commitedit (Datagridviewdataerrorcontexts.commit); }}//If A check box cell is clicked, this event handler disables//or enables the button in the same row as the clicked cell.public void Datagridview1_cellvaluechanged (object sender, DataGridViewCellEventArgs e) {if (datagridview1.colum Ns[e.columnindex]. Name = = "checkboxes") {DataGridViewDisableButtonCell Buttoncell = (datagridviewdisablebuttoncell) dat            AGridView1. Rows[e.rowindex].        cells["Buttons"];            Datagridviewcheckboxcell Checkcell = (Datagridviewcheckboxcell) dataGridView1. Rows[e.rowindex].        cells["checkboxes"]; buttoncell.enabled =!        (Boolean) Checkcell.value;    Datagridview1.invalidate (); }}

 

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.