Datagirdview when you create a row, the mouse clicks the data to become blank.

Source: Internet
Author: User

Use datagridview today

The init code in form is as follows:

Datagridview1.setcolumn (typeof (debtnormal), epropertyfieldfilter. all); var debtinfo = new debtnormal (); debtinfo. bond code = "test"; var ROW = new datagridviewrow (); row. tag = debtinfo; datagridview1.rows. add (ROW); row. setrowvalues (debtinfo. toitems (epropertyfieldfilter. field); _ dtdebtrow. add ("test", row );

At this time, everything works normally after the datagridview1 is started. We can see that the new datagridviewrow () statement is used here.

However, add a new row in the running process,

The statement is as follows:

Void _ parsedebtnormalinfo_ondataupdated (debtnormal arg_debtinfo) {This. Invoke (new action () => {If (! _ Dtdebtnormal. containskey (arg_debtinfo. bond Code) _ dtdebtnormal. add (arg_debtinfo. bond code, arg_debtinfo); // datagridview1.datasource = NULL; // datagridview1.datasource = _ dtdebtnormal. values. toarray (); var debtinfo = arg_debtinfo; var ROW = (datagridviewrow) NULL; If (_ dtdebtrow. trygetvalue (debtinfo. bond code, out row) {debug. set (debtinfo. bond code, "hello");} else {ROW = new datagridviewrow (); // datagridview1.rows [datagridview1.rows. add ()-1]; datagridview1.rows. add (ROW); // row. tag = debtinfo; _ dtdebtrow. add (debtinfo. bond code, row); row. setrowvalues (debtinfo. toitems (epropertyfieldfilter. field);} var rowtest = _ dtdebtrow ["test"]; var dinfotest = rowtest. tag as debtnormal; dinfotest. subject rating = "pig"; rowtest. setrowvalues (arg_debtinfo.toitems (epropertyfieldfilter. field); // row. setrowvalues (dinfotest. toitems (epropertyfieldfilter. field ));}));}

Here we also use the new datagridviewrow () statement. At this time, the running data is displayed normally, but once you click the newly created data, we will find that it becomes blank.

You must change the code of New datagridviewrow () to datagridview1.rows. Add (); enable it to be automatically added internally, and then set this row.

Row = maid [maid. add ()-1]; // row. tag = debtinfo; _ dtdebtrow. add (debtinfo. bond code, row); row. setrowvalues (debtinfo. toitems (epropertyfieldfilter. field ));

So there is no problem.

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.