Continuation of the DataGrid refresh question raised by kinbor

Source: Internet
Author: User
Http://kinbor.cnblogs.com/archive/2005/11/04/269152.html

After reading the question raised by kinbor on the above page, I found it interesting, but there is no texture, so I moved it here, although I do not advocate using the method of assigning values to the DataGrid in this set-value application (I think it is better to change the data source as he said, because the DataGrid is exposed, there are too many uncertainties), but this issue is worth exploring.

In addition Article In addition to the content added in the comments, I added a section in the DataGrid scroll event. Code To output the current row. Private   Void Dginfo_scroll ( Object Sender, system. eventargs E)
{
Strmessage+ ="Scroll, row: \ t" +Dginfo. currentcell. rownumber. tostring ()+ "\ N";
}

Private   Void Tbinfo_leave ( Object Sender, system. eventargs E)
{
Classtest clstest =   New Classtest ();
// Dginfo. Enabled = false;
For (; Clstest. itempvalue < 15 ; Clstest. Improve ())
{
Strmessage + =   " Loop, before: "   + Clstest. itempvalue. tostring () +   " \ N " ;
Dginfo [clstest. itempvalue, 4 ] = Clstest. itempvalue. tostring () +   " - "   + Tbinfo. text;
Dginfo. Refresh ();
Strmessage + =   " Loop, after: \ t "   + Clstest. itempvalue. tostring () +   " \ N ------------------------------------------- \ n " ;
}
// Dginfo. Enabled = true;
}

Let's take a look at the output strmessage content:

We can see that the loop contentStrmessage+ = "Loop, before:" +Clstest. itempvalue. tostring ()+ "\ N";

The command is executed twice in total, but the output statement after cell assignment is not executed, as if in the assignment process,ProgramThe variable is automatically reduced by 1, and then the continue is the same, and the 8th rows are exactly the number of rows stopped after the DataGrid is rolled. This can be seen from the result of dragging the scroll bar after the final assignment.

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.