开始走了弯路,以为是用GetNextItem(),结果却只能第一个column的属性值。
后来搜索官方的wiki,才发现这儿已经提供了解决方案:
wxString MyListCtrl::GetCellContentsString( long row_number, int column )
{
wxListItem row_info;
wxString cell_contents_string;// Set what row it is (m_itemId is a member of the regular wxListCtrl class)
row_info.m_itemId = row_number;
// Set what column of that row we want to query for information.
row_info.m_col = column;
// Set text mask
row_info.m_mask = wxLIST_MASK_TEXT;// Get the info and store it in row_info variable.
GetItem( row_info );// Extract the text out that cell
cell_contents_string = row_info.m_text;return cell_contents_string;
}
另外一种方法:
bool MyListCtrl::GetCellContentsString( long row_number, int column, wxString& cell_contents_string ) const
{
wxListItem row_info;// Set what row it is (m_itemId is a member of the regular wxListCtrl class)
row_info.m_itemId = row_number;
// Set what column of that row we want to query for information.
row_info.m_col = column;
// Set text mask
row_info.m_mask = wxLIST_MASK_TEXT;// Get the info and store it in row_info variable.
if (GetItem( row_info ))
{
// Extract the text out that cell
cell_contents_string = row_info.m_text;
return true;
}return false;
}
发表回复