Hello All,
As per your suggestion, i have been trying to learn MFC and try to replicate the problem i am solving in the legacy code.
I have comeup with the following code:, But the issue here is the list is growing in the opposite direction from what i was expecting !!!
Sorry my code maynot be well written, but i am able to replicate the issue i have.
![Name: Capture.PNG
Views: 7
Size: 7.6 KB]()
What i wanted is:
Cell Site
first site1
site3
site4
second site4
site5
site6
Basically, first has sites 1,3,4 and second has sites 4,5 ,6
Hope i am able to convey the problem i am facing
thanks a lot
Again, thanks a lot for having patience with my naive questions..
Merry Christmas and Happy new year
Best wishes
Pdk
As per your suggestion, i have been trying to learn MFC and try to replicate the problem i am solving in the legacy code.
I have comeup with the following code:, But the issue here is the list is growing in the opposite direction from what i was expecting !!!
Code:
map<int, vector<int>> m = { { 1, {1,3,4 }} ,{ 2, {4,5,6 } } };
map<int, string> n = { { 1, "Site1", } , { 2, "Site2"} ,{ 3, "Site3" },{ 4, "Site4" },{ 5, "Site5" },{ 6, "Site6" } };
BOOL CMFCApplication2Dlg::OnInitDialog()
{
// TODO: Add extra initialization here
priya_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_ONECLICKACTIVATE);
int nItem = priya_list.InsertColumn(0, _T("Cell"), LVCFMT_LEFT, -1, 0);
priya_list.InsertColumn(1, _T("Site"), LVCFMT_LEFT, -1, 0);
int centralsite;
vector<int> sites;
bool bIsfirstCentralsite(false);
for (const auto pair : m)
{
bIsfirstCentralsite = true;
string centreId;
int index = pair.first;
if (index == 1)
{
centreId = "first";
}
else
{
centreId = "second";
}
CString ccetre(centreId.c_str());
for (const auto site : pair.second)
{
int nItem(0);
if(bIsfirstCentralsite)
nItem = priya_list.InsertItem(0, ccetre);
else
nItem = priya_list.InsertItem(0, _T(""));
auto itr = n.find(site);
string sSiteId = itr->second;
CString cSiteId(sSiteId.c_str());
priya_list.SetItemText(nItem, 1, cSiteId);
bIsfirstCentralsite = false;
}
}
}What i wanted is:
Cell Site
first site1
site3
site4
second site4
site5
site6
Basically, first has sites 1,3,4 and second has sites 4,5 ,6
Hope i am able to convey the problem i am facing
thanks a lot
Again, thanks a lot for having patience with my naive questions..
Merry Christmas and Happy new year
Best wishes
Pdk