I put here a SQLite
example that uses https://github.com/SqliteModernCpp/sqlite_modern_cpp library to populate a CListCtrl
, as you wanted.
#include <sqlite_modern_cpp.h>
CListCtrl listCtrl;
// set listCtrl as detail mode and setup 3 columns
try {
sqlite::database db("c:/temp/test.db3", config);
for (auto&& row : db << "select age,name,weight from user")
{
int age; std::string name; double weight;
row >> age >> name >> weight;
const auto count = listCtrl.GetItemCount();
listCtrl.Insert(count, name.c_cstr());
listCtrl.SetItemText(count, 1, std::to_string(age));
listCtrl.SetItemText(count, 2, std::to_string(weight));
}
}
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
}