为了满足需要,就是当在某行最后一列按向右方向键,要回到该行第一列
因为datagrid默认,但该最后一列时再按右是回到下行第一列
为此,我响应了BOOL CTableView::PreTranslateMessage(MSG* pMsg)
if(pMsg->message==WM_KEYDOWN && isDrag==false){
if(pMsg->wParam==VK_RIGHT && m_grid.GetCol()==m_grid.GetColumns().GetCount()-1){
m_grid.SetCol(1);
m_grid.SetLeftCol(0);
return TRUE;
}
if(pMsg->wParam==VK_LEFT && m_grid.GetCol()==1)
return TRUE;
}
可是,假如某行最后一列是30,当按右时,确实转到了该行第一列,但是该行第一列的值却变成了30!!!
这是怎么回事,问题好像就出在m_grid.SetCol(1);
因为datagrid默认,但该最后一列时再按右是回到下行第一列
为此,我响应了BOOL CTableView::PreTranslateMessage(MSG* pMsg)
if(pMsg->message==WM_KEYDOWN && isDrag==false){
if(pMsg->wParam==VK_RIGHT && m_grid.GetCol()==m_grid.GetColumns().GetCount()-1){
m_grid.SetCol(1);
m_grid.SetLeftCol(0);
return TRUE;
}
if(pMsg->wParam==VK_LEFT && m_grid.GetCol()==1)
return TRUE;
}
可是,假如某行最后一列是30,当按右时,确实转到了该行第一列,但是该行第一列的值却变成了30!!!
这是怎么回事,问题好像就出在m_grid.SetCol(1);
if(pMsg->message==WM_KEYDOWN ){
if(pMsg->wParam==VK_RIGHT && m_grid.GetCol()==m_grid.GetColumns().GetCount()-1){
pMsg->wParam=VK_HOME;
}
if(pMsg->wParam==VK_LEFT && m_grid.GetCol()==1)
return TRUE;
}
把它强行改称wk_home,因为按home键是回到该行首列的
但是实在不清楚之前的m_grid.SetCol(1); 为什么会错忘了说了,我第一列被隐藏了,所以用的是SetCol(1)