如何根据某些条件在MFC中链接两个列表框 [英] How to Link two list box in mfc based on some criteria

查看:85
本文介绍了如何根据某些条件在MFC中链接两个列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想链接两个列表框,其中一个列表框包含水果,花朵,蔬菜等物品的列表.第二个列表是芒果,橙色,玫瑰,郁金香,莲花,向日葵,苹果,黄瓜,西红柿.

当我在一个列表中选择水果时,仅水果应显示在另一列表中,而当我选择蔬菜时,仅蔬菜(黄瓜,西红柿)应在另一列表中显示.

I want to link two list box where one list box has list of items like fruits, flowers,vegetables. and second list has mango,orange,rose,tulip,lotus,sunflower,apple,cucumber,tomato.

When i select fruit in one list only fruits should be shown in the other list and when i select vegetables only vegetables(cucumber,tomato) should be listed in another list.

How to link such list?

推荐答案

CString str1;
	int Patch = m_grp_Inst.GetCurSel();
	m_grp_Inst.GetText(Patch,str1);
if(str1="fruits")
{
m_gmList.AddString("Mango");
}


使用这个,我在str1中有一个字符串,并基于将字符串添加到另一个列表中.


using this i have got string in str1 and based add string to the another list


这个想法是为此编写代码.


处理list1的项目选择事件,并根据list1中的选定项目填充list2.
The idea is to write code for this.


Handle the item select event of list1 and populate list2 based on the selected item in list1.


这篇关于如何根据某些条件在MFC中链接两个列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆