您的位置:首页 > 其它

VC:CListBox(添加项、设置图片、获取总项数、获取选中的项、获取项文本)

2012-10-17 21:28 148 查看
1、初始化:对话框属性中Selection项,选择Multiple

m_listbox.AddString("Colomn1");

m_listbox.AddString("Colomn2");

m_listbox.AddString("Colomn3");

m_listbox.AddString("Colomn4");

m_listbox.InsertString(1,"Insert 1");

m_listbox.InsertString(2,"Insert 2");

// m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

//HICON hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);

// m_listbox.SetIcon(m_hIcon,true);

2、获取列表框信息

CString message="您的爱好有:";

CString str;

int num=m_listbox.GetSelCount();

int m[10];

for(int i=0;i<10;i++)

{

m[i]=-1;

}

m_listbox.GetSelItems(num,m);

for(int j=0;j<10;j++)

{

if(m[j]!=-1)

{

m_listbox.GetText(m[j],str);

message+=str;

}

}

AfxMessageBox(message);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐