Gridctrl Study Notes (2) Find ways to automatically update the table's latest data and display it to the current window

Source: Internet
Author: User

Once the project is set up, you can start looking for ways to do so.

1, first, create a button, each press, you can update the contents of the non-current lattice, this is easy to achieve: void cgridcontroltest02dlg::onbnclickedfillbox () { //Todo:add your control notification handler code hereGv_item ITEM;Item.mask = gvif_text| Gvif_format;item.row = up;item.col = 2;Item.nformat = dt_center| dt_vcenter| dt_singleline| dt_end_ellipsis;Item.strText.Format (_t ("the"), 2);M_pgrid.setitem (&item);M_pgrid.refresh (); //ccellid cell (56,2); //m_pgrid.setfocuscell (cell);//method of setting focus }2, then, always find a way, until I see GridCtrl.h in the Protect in this function (BOOL SetScrollPos32 (int nBar, int nPos, BOOL bredraw = TRUE); ), and then look at the front and rear code that uses it, and find that it can be called. but unfortunately, it is protect, I change it to public also can not be compiled. later, consult a colleague, found that in the public and use it in an instantiated way, the compiler passed. as follows: int scrollpos = m_pgrid.getscrollpos32 (Sb_vert);  3, then, I can try to use my method to try: First get the current POS position, and then calculate offset, so that the current +offset, you can jump to the location of the content update:
int scrollpos = m_pgrid.getscrollpos32 (Sb_vert); ccellid idtopleft = M_pgrid.gettopleftnonfixedcell (); int yscroll = m_pgrid.getrowheight (idtopleft.row) * (item.row-1);m_pgrid.setscrollpos32 (Sb_vert, Scrollpos + yscroll);4, after compiling, and this method is feasible. The next step is to fix this method because there is a bug now.

Gridctrl Study Notes (2) Find ways to automatically update the table's latest data and display it to the current window

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.