What is a correct way to fill wxGrid from wxSQLite3Table? Topic is solved

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
psion_revo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Feb 07, 2016 10:13 am

What is a correct way to fill wxGrid from wxSQLite3Table?

Post 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!
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

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

Post 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
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
psion_revo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Feb 07, 2016 10:13 am

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

Post 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);