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.
Post Reply
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 » Wed Feb 10, 2016 8:21 pm

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: 2240
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

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

Post by evstevemd » Sat Feb 13, 2016 8:45 am

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

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 » Sun Feb 14, 2016 11:09 am

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

Post Reply