MFC : Not able to populate db records in list control of MFC SDI application
-
Hi All, I am struggling these days in creating an MFC application which has following problem statement: --> In MFC, Create an UI list control which will populate data from one table using db connectivity. What I have done so far : --> Created a SDI MFC application, --> Able to connect to db, fetch record in "Edit Box" and traverse between records(First,Last,Next,Previous). where I am stuck: --> I am not able to populate these records in List control. I have taken reference from "c++ - How to add items to a List Control in an MFC dialog - Stack Overflow[^]" but it has asked to write code under "OnInitDialog" method which is not present in SDI application. Though I can able to see this method in Dialog based MFC application but not in SDI application. Request you to all to please help me. Thanks, Sanjeev
-
Hi All, I am struggling these days in creating an MFC application which has following problem statement: --> In MFC, Create an UI list control which will populate data from one table using db connectivity. What I have done so far : --> Created a SDI MFC application, --> Able to connect to db, fetch record in "Edit Box" and traverse between records(First,Last,Next,Previous). where I am stuck: --> I am not able to populate these records in List control. I have taken reference from "c++ - How to add items to a List Control in an MFC dialog - Stack Overflow[^]" but it has asked to write code under "OnInitDialog" method which is not present in SDI application. Though I can able to see this method in Dialog based MFC application but not in SDI application. Request you to all to please help me. Thanks, Sanjeev
With not dialog based applications you should derive your view class from CListView Class[^]. That can then be populated with the recordsets using the CListView::GetListCtrl[^] function to get a reference to the list control. The
OnInitDialog()
corresponding function for views is CView::OnInitialUpdate[^]. See also the example code at theGetListCtrl()
link.