I have a wxDialog containing, among other sizers and controls, a wxGrid one. Initially, i set the wxgrid to have only 1 row and 1 col.
When i parse the file, i then add the columns and rows to accomodate the data.
The problem is to resize the wxDialog and wxGrid to acommodate the data in the wxGrid.
Code: Select all
m_datapreview->AppendCols(c.fields, true);
m_datapreview->AppendRows(c.rows, true);
csv_free(&p);
//exit(EXIT_SUCCESS);
for(f=0;f<(int)c.fields;f++)
{
for(r=0;r<(int)c.rows;r++)
{
tmp = dados[r][f];
str = wxString(tmp,wxConvUTF8);
m_datapreview->SetCellValue(r,f,str);
}
}
m_datapreview->Fit();
this->SetClientSize(m_datapreview->GetSize());
m_datapreview->Update();
//this->SetSizeHints( -1, -1 );
this->Layout();
//this->Update();
this->Fit();
m_datapreview->Fit();
The most stable code that i could write is shown below:
Code: Select all
m_datapreview->Fit();
this->SetClientSize(m_datapreview->GetSize());
this->SetSizeHints( 640, 480 );
m_datapreview->Update();
this->Layout();
//this->Update();
this->Fit();
m_datapreview->Fit();