CGrid 设置视图与滚动条同步

最近在用CGrid,实现通过下拉框定位到CGrid的一个单元格

void CCGridTestDlg::OnSelchangeTestGroupNum()
{
    // TODO: Add your control notification handler code here
    int static oldgroup;
    int group = m_TestGroupNum.GetCurSel();          //m_TestGroupNum是下拉框控件
    oldgroup = group;
    m_Grid.SetFocusCell(group, 1);                    //设置焦点选中单元格
    int yScroll = group*m_Grid.GetRowHeight(0);
    m_Grid.SetScrollPos(SB_VERT, yScroll, true);     //滚动视图到指定单元格
    if(group>oldgroup)
       m_Grid.SendMessage(WM_VSCROLL, SB_LINEDOWN, 0); //m_Grid是CGrid控件
    else
       m_Grid.SendMessage(WM_VSCROLL, SB_LINEUP, 0);
}


你可能感兴趣的:(CGrid 设置视图与滚动条同步)