在listcontrol MFC中显示多行 [英] Show multiple rows in listcontrol MFC

查看:351
本文介绍了在listcontrol MFC中显示多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计



我的MFC对话框中有一个listcontrol元素(View-> Report)。

我想要什么:2列,所有行从数据库中读出



我试过:

Hey guys

I got a listcontrol element in my MFC-dialog (View->Report).
What I wanted: 2 columns, all rows read out from database

I tried:

LVITEM lvItem;

m_List.InsertColumn(1, "First Column", 0, 150, 1);   // could be created
m_List.InsertItem(1, "First Row");   // could NOT be created



InsertItem ..无法创建,所以我尝试了另一种方式......


"InsertItem.." could not be created, so I tried another way...

lvItem.mask = LVIF_TEXT;
lvItem.iItem = 0;
lvItem.iSubItem = 0;
lvItem.pszText = "Row one";
m_List.InsertItem(&lvItem);





我做错了什么或者我必须添加别的东西?





问候

Epanjohura



What am I doing wrong or do I have to add something else?


Greetings
Epanjohura

推荐答案

项目和列索引从0开始。如果要包含两列,则必须插入两列:

Item and column indexes start at 0. If you want to have two columns, you must insert two:
InsertColumn(0, _T("Column 1"), LVCFMT_LEFT, 100, 0);
InsertColumn(1, _T("Column 2"), LVCFMT_LEFT, 100, 1);



然后将项添加到列表中 InsertItem()指定第一列中显示的主项,其他列由 SetItemText()


Then add items to the list where InsertItem() specifies the main item which is shown in the first column and the additional columns are specified by SetItemText():

InsertItem(0, _T("Item 1-1"));
SetItemText(0, 1, _T("Item 1-2"));
InsertItem(1, _T("Item 2-1"));
SetItemText(1, 1, _T("Item 2-2"));


嗯,就是这样一个愚蠢的错误...



我试过......最后,我只需要更改一些属性:



所有者数据:错误

所有者提取固定:错误





问候

Epanjohura
Well, it was such a stupid fault...

I tried and tried...finally, I just had to change some properties:

Owner Data : False
Owner Draw Fixed : False


Greetings
Epanjohura


这篇关于在listcontrol MFC中显示多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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