本文整理汇总了C++中wxGrid::SetCellValue方法的典型用法代码示例。如果您正苦于以下问题:C++ wxGrid::SetCellValue方法的具体用法?C++ wxGrid::SetCellValue怎么用?C++ wxGrid::SetCellValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxGrid
的用法示例。
在下文中一共展示了wxGrid::SetCellValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnOpen
void MyFrame::OnOpen(wxCommandEvent & WXUNUSED(event)) {
wxFileDialog dialog(this, wxEmptyString, wxEmptyString, wxEmptyString, wxEmptyString,
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (dialog.ShowModal() == wxID_OK) {
wxString filename(dialog.GetPath());
wxTextFile text_file(filename);
if (!text_file.Open(wxConvUTF8)) {
return;
}
grid->EnableEditing(false);
if (text_file.GetLineCount() > grid->GetNumberRows()) {
grid->AppendRows(text_file.GetLineCount() - grid->GetNumberRows());
} else if (text_file.GetLineCount() < grid->GetNumberRows()) {
grid->DeleteRows(text_file.GetLineCount(), grid->GetNumberRows() - text_file.GetLineCount());
}
grid->ClearGrid();
for (int row = 0; row < text_file.GetLineCount(); ++row) {
wxStringTokenizer tokenizer(text_file[row], L",");
for (int col = 0; tokenizer.HasMoreTokens() && col < grid->GetNumberCols(); ++col) {
wxString token = tokenizer.GetNextToken();
grid->SetCellValue(row, col, token);
}
}
grid->AutoSize();
text->Clear();
lines.clear();
for (int row = 0; row < text_file.GetLineCount(); ++row) {
lines.push_back(text_file[row]);
}
text_file.Close();
topsizer->Layout();
SetStatusText(wxFileName(filename).GetFullName());
}
}
示例2: PopulateWXGridFromDataGrid
void PopulateWXGridFromDataGrid(const CDataGrid& rSrcDataGrid, wxGrid& rDestWXGrid)
{
// Remove old rows, and insert new ones as appropriate
rDestWXGrid.DeleteCols(0, rDestWXGrid.GetNumberCols());
rDestWXGrid.DeleteRows(0, rDestWXGrid.GetNumberRows());
rDestWXGrid.AppendCols(rSrcDataGrid.GetNumberCols());
rDestWXGrid.AppendRows(rSrcDataGrid.GetNumberRows());
rDestWXGrid.SetDefaultCellTextColour(wxColour(0, 0, 0));
rDestWXGrid.SetLabelTextColour(wxColour(0, 0, 0));
rDestWXGrid.SetRowLabelSize(0);
rDestWXGrid.EnableDragRowSize(false);
// Top Headings
for (int iCol = 0; iCol < rSrcDataGrid.GetNumberCols(); iCol++)
{
rDestWXGrid.SetColLabelValue(iCol, wxString(rSrcDataGrid.GetTopHeadingText(iCol), wxConvUTF8));
}
for (int iRow = 0; iRow < rSrcDataGrid.GetNumberRows(); iRow++)
{
// Side Heading
rDestWXGrid.SetRowLabelValue(iRow, wxString(rSrcDataGrid.GetSideHeadingText(iRow), wxConvUTF8));
// Data Row
for (int iCol = 0; iCol < rSrcDataGrid.GetNumberCols(); iCol++)
{
rDestWXGrid.SetCellValue(iRow, iCol, wxString(rSrcDataGrid.GetCellText(iRow, iCol), wxConvUTF8));
rDestWXGrid.SetReadOnly(iRow, iCol, true);
wxFont vCellFont = rDestWXGrid.GetCellFont(iRow, iCol);
if (rSrcDataGrid.IsCellBold(iRow, iCol))
vCellFont.SetWeight(wxFONTWEIGHT_BOLD);
if (rSrcDataGrid.IsCellUnderlined(iRow, iCol))
vCellFont.SetUnderlined(true);
rDestWXGrid.SetCellFont(iRow, iCol, vCellFont);
}
}
rDestWXGrid.AutoSizeColumns(false);
rDestWXGrid.AutoSizeRows(false);
}