Page 1 of 1

What is a correct way to fill wxGrid from wxSQLite3Table?

Posted: Wed Feb 10, 2016 8:21 pm
by psion_revo
I don't want double buffering.
First, I've got wxSQLite3Table as a result of execution of my SQL query.
Second, I need to copy all data from wxSQLite3Table to wxGrid.
Third, I need to destroy wxSQLite3Table.

Is it a correct way?
Thanks!

Re: What is a correct way to fill wxGrid from wxSQLite3Table?

Posted: Sat Feb 13, 2016 8:45 am
by evstevemd
You need to create your GridTable Class and associate it with your Grid. The Table class will do the data part and Grid will do the view part
See http://docs.wxwidgets.org/trunk/classwx ... _base.html

Re: What is a correct way to fill wxGrid from wxSQLite3Table?

Posted: Sun Feb 14, 2016 11:09 am
by psion_revo
evstevemd wrote:You need to create your GridTable Class
Thanks! Will try to do it.

Now, I just can fill wxGrid from a table like this.

Code: Select all

  
  try {
    wxSQLite3Statement ls=db->PrepareStatement("SELECT id,name FROM table ORDER BY id");
    wxSQLite3ResultSet lr=ls.ExecuteQuery();
    int ln=lr.GetColumnCount();
    grid_table->CreateGrid(0,ln);
    int lrow=0;
    while (lr.NextRow()){
      grid_table->AppendRows(1);
      for (int li=0;li<ln;li++) {
        if (!lr.IsNull(li)) grid_table->SetCellValue(lrow,li,lr.GetString(li));
      }
      lrow++;
    }
    ls.Finalize();
  } catch (int le) {

  }
  grid_table->SetRowLabelSize(0);